The younger brother encountered a problem when using PropertyGrid. Please help me.
The problem is as follows:
Suppose there is a program like this
This section of code is roughly as follows:
Namespace PropertyTest {
Public partial class Form1: Form {
Public Form1 (){
InitializeComponent ();
PropertyGrid1.SelectedObject = new Fun ();
}
}
Public class Fun {
Private List <TestArray> test = new List <TestArray> ();
Public string Name {get; set ;}
Public int Num {get; set ;}
Public List <TestArray> Test {get; set ;}
}
}
Click Test to enter the following form:
Text is bound to a custom form. The TestArray code is as follows:
Public class TestArray {
Public string TempName {get; set ;}
Public int TempNum {get; set ;}
[Editor (typeof (TextEditor), typeof (System. Drawing. Design. UITypeEditor)]
Public string Text {get; set ;}
}
The Editor code is as follows:
Namespace PropertyTest {
Public class TextEditor: UITypeEditor {
Public override UITypeEditorEditStyle GetEditStyle (ITypeDescriptorContext context ){
Return UITypeEditorEditStyle. Modal;
}
Public override object EditValue (ITypeDescriptorContext context, IServiceProvider provider, object value ){
IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService) provider. GetService (typeof (IWindowsFormsEditorService ));
If (edSvc! = Null ){
TextInput t = new TextInput (edSvc );
EdSvc. ShowDialog (t );
Return t. S;
}
Return value;
}
}
}
My problem is how to get the Name and Num values of the top-level window in EditValue of Editor. Please help.