Using the Windows Forms Property Editor .NET Control

Measurement Studio 2019 Help

Edition Date: May 2019

Part Number: 375857B-01

»View Product Info
Download Help (Windows Only)

You use the PropertyEditor control to edit property values at run time using their associated editors. The editor displayed by the PropertyEditor control is the same editor that is displayed when you edit the property at design time.

Source represents the property to edit. To edit a property of an object, you must set the Source property with an object reference and the property name on that object. The following example shows how to set the Source property so that you can edit the ScaleArc value on a Knob control. The example assumes that a Knob control called knob1 and a PropertyEditor control called propertyEditor1 have been declared and initialized.


PropertyEditor1.Source = New PropertyEditorSource(Knob1, "ScaleArc")

propertyEditor1.Source = new PropertyEditorSource(knob1, "ScaleArc");

Use SourceValue to get the value of the property being edited, and use FormattedSourceValue to get the string representation of the property value. You can call EditValue to launch the associated editor programmatically. Use IsEditingValue to determine if a property is being edited.

You also can edit the property value by typing the value of the property into the PropertyEditor control. If the property value cannot be converted to a valid value, the SourceValueWarning event is raised. You can use the SourceValueWarning event to set the SourceValue property to a valid value. If SourceValue is not set to a valid value in the event, the PropertyEditor control reverts to the previous value.

You can change the way end users interact with the control through the InteractionMode property. You can customize the appearance of the control by setting the BorderStyle, RenderMode, DisplayMode, and TextAlign properties. You use RenderMode to determine the style used to draw the control. The RenderMode value only applies when BorderStyle is BorderStyle .

Extending the Property Editor Control

You can customize the editor displayed by the PropertyEditor control and the type converter used by the control to convert to and from the text representation of the property value through extension. Create a derived class of PropertyEditorSource and override the Editor property to return a custom editor derived from the UITypeEditor base class. You can also override the Converter property in a derived class to specify a custom type converter derived from TypeConverter . The PropertyEditor control uses the custom type converter to convert a property value to and from its text representation.


Not Helpful