Use the editor from the following article to reproduce: https://docs.telerik.com/devtools/winforms/propertygrid/editors/using-custom-editor Workaround: void TrackBarEditor_ValueChanged(object sender, EventArgs e) { PropertyGridItemElement owner = this.OwnerElement as PropertyGridItemElement; if (owner != null) { var method = owner.PropertyTableElement.GetType().GetMethod("OnValueChanged", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); method.Invoke(owner.PropertyTableElement, new object[] { this, EventArgs.Empty }); } }
Problem: I'd like to filter the properties to be displayed by their category names defined by the Category attribute. Based on the doc here (https://docs.telerik.com/devtools/winforms/controls/propertygrid/features/filtering), my understanding is to add a FilterDescriptor like this: New FilterDescriptor ("Category", FilterOperator.Contains, "some category name"). But it turned out to only filter by property name, not category name. Any misunderstanding or possible issue? Thank you for looking into this.
Reproduce:
1. Define a class like this:
Private Class TestClass
<Category("Cat1")> Public Property Property1 As Integer = 1
<Category("Cat1")> Public Property Property2 As String = "Test 2"
<Category("Cat2")> Public Property Property3 As String = "Test 3"
End Class
2. Initialize a RadPropertyGrid in the Form.Load event:
Dim testObj As New TestClass
RadPropertyGrid1.EnableFiltering = True
Dim filter As New FilterDescriptor("Category", FilterOperator.Contains, "2")
RadPropertyGrid1.FilterDescriptors.Add(filter)
RadPropertyGrid1.SelectedObject = testObj
3. The right property to be displayed should be Property3, but it turned out to be Property2
Example project: attached.
Thank you team!
1. Create a custom property item
2. Enable grouping
3.Scroll up and down
4.NullReferenceException occurs
Use the following code snippet and try to edit the Height. You will notice that the sub-items' order is changed:
RadPropertyStore store = new RadPropertyStore();
PropertyStoreItem sizeItem = new PropertyStoreItem(typeof(System.Drawing.Size), "Size", new System.Drawing.Size(100, 25), "The size of the control in pixels.", "Layout");
store.Add(sizeItem);
this.radPropertyGrid1.SelectedObject = store;
this.radPropertyGrid1.SortOrder = SortOrder.Ascending;
this.radPropertyGrid1.PropertySort = PropertySort.Alphabetical;
The clients needs to use a PropertyGridDropDownListEditor and confirms the new value whenever a new selection is made. The attached gif file illustrates how to replicate the error using the following code snippet:
public RadForm1()
{
InitializeComponent();
this.radPropertyGrid1.SelectedObject = this;
this.radPropertyGrid1.EditorInitialized += radPropertyGrid1_EditorInitialized;
}
private void radPropertyGrid1_EditorInitialized(object sender, PropertyGridItemEditorInitializedEventArgs e)
{
PropertyGridDropDownListEditor ddl = e.Editor as PropertyGridDropDownListEditor;
if (ddl != null)
{
ddl.LoopValuesOnDoubleClick = false;
BaseDropDownListEditorElement element = ddl.EditorElement as BaseDropDownListEditorElement;
if (element != null)
{
element.SelectedValueChanged -= Element_SelectedValueChanged;
element.SelectedValueChanged += Element_SelectedValueChanged;
}
}
}
private void Element_SelectedValueChanged(object sender, Telerik.WinControls.UI.Data.ValueChangedEventArgs e)
{
this.radPropertyGrid1.EndEdit();
}
Workaround:
public RadForm1()
{
InitializeComponent();
this.radPropertyGrid1.SelectedObject = this;
this.radPropertyGrid1.ValueChanged += RadPropertyGrid1_ValueChanged;
}
private void RadPropertyGrid1_ValueChanged(object sender, EventArgs e)
{
if (this.radPropertyGrid1.ActiveEditor is PropertyGridDropDownListEditor)
{
this.radPropertyGrid1.EndEdit();
}
}