So, I decided to put all the information I collected, with fully functional working examples in VB.NET (which is my favorite) and let me tell you, it is the most complex control of all controls in VS.NET, yet very powerful and extremely useful, particularly in Custom Controls, and for Application Configuration settings. That's it, surprising, and not even a single example in VB.NET that compiles without errors and explains all in and outs of PropertyGrid control. I tried to get information on that, from Microsoft and searching all over Internet, newsgroups, but I could find only a couple of articles from Microsoft. Public Class DefaultPropertyGridItemElementīack to the control, let’s subscribe to the RadPropertyGrid.For my last project, I had a requirement where I can use PropertyGrid control. Public Overrides Function IsCompatible(data As PropertyGridItemBase, context As Object) As Boolean Protected Overrides ReadOnly Property ThemeEffectiveType() As Type Return New CustomPropertyGridValueElement() Protected Overrides Function CreatePropertyGridValueElement() As PropertyGridValueElement Public class DefaultPropertyGridItemElement : PropertyGridItemElement Public override bool IsCompatible(PropertyGridItemBase data, object context) Protected override Type ThemeEffectiveType Return new CustomPropertyGridValueElement()
Protected override PropertyGridValueElement CreatePropertyGridValueElement() Public class CustomItemElement : PropertyGridItemElement In addition, it is necessary to create another PropertyGridItemElement which is not compatible with your custom item: Custom PropertyGridItemElements IsCompatible method and control whether the custom element is applicable for the specific PropertyGridItem. In order to avoid reusing of the custom element for other items, you can override the PropertyGridItemElement. To put this value element in action, we will create a descendant of PropertyGridItemElement, and we will override its CreatePropertyGridValueElement method. Thenįor Each rb As RadRadioButtonElement In stackPanel.Children If item IsNot Nothing AndAlso rb.Text item.FormattedValue AndAlso rb.ToggleState = ToggleState. Private Sub rb_ToggleStateChanged(sender As Object, args As StateChangedEventArgs)ĭim rb As RadRadioButtonElement = Tr圜ast(sender, RadRadioButtonElement)ĭim item As PropertyGridItem = Tr圜ast(Me.VisualItem.Data, PropertyGridItem) GetValues(GetType(DeliveryType))ĪddHandler rb.ToggleStateChanged, AddressOf rb_ToggleStateChanged StackPanel.Orientation = Orientation.Verticalįor Each enumItem As Object In. Protected Overrides Sub CreateChildElements() Public Class CustomPropertyGridValueElement If (item != null & rb.Text != item.FormattedValue & rb.ToggleState = ToggleState.On)įoreach (RadRadioButtonElement rb in stackPanel.Children) PropertyGridItem item = as PropertyGridItem RadRadioButtonElement rb = sender as RadRadioButtonElement Private void rb_ToggleStateChanged(object sender, StateChangedEventArgs args) Rb.ToggleStateChanged += rb_ToggleStateChanged RadRadioButtonElement rb = new RadRadioButtonElement() StackPanel.Orientation = Orientation.Vertical įoreach (var enumItem in Enum.GetValues(typeof(DeliveryType))) Protected override void CreateChildElements()
Public class CustomPropertyGridValueElement : PropertyGridValueElement Our custom implementation of the PropertyGridValueElement will demonstrate how to insert radio buttons for the Item. Next, we should create a custom PropertyGridValueElement which is purposed to be used in a derived PropertyGridItemElement. Public Sub New(id As Integer, title As String, deliveryType As DeliveryType)
Public Property DeliveryType() As DeliveryType Public Item(int id, string title, DeliveryType deliveryType)