In some cases when the selected object is changed while a bool property is selected an InvalidCastExceptions is thrown. Check ticket for reproduction steps and project.
RadPropertyGrid calls the TypeConverter methods GetStandardValuesSupported and GetStandardValues passing null as parameter when it should pass the property item. Code to reproduce: this.radPropertyGrid1.SelectedObject = new SomeClass(); public class SomeClass { [TypeConverter(typeof(CustomValueConverter))] public string CustomValue { get; set; } } public class CustomValueConverter : TypeConverter { public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return base.GetStandardValues(context); } }
When editing a DateTime? property the property grid shows a text box editor instead of calendar.
When setting multiple objects or a mix of objects, some of which implement the INotifyPropertyChanged interface changes in these objects should be reflected in the RadPropertyGrid.
The RadPropertyGrid implementation should be improved in a way that will allow users to override the methods that fire events like: OnEditorRequired, OnEditorInitialized, OnCustomGrouping etc. Resolution: 1. Inherit from PropertyGridTableElement and override the method you want. 2. Inherit from PropertyGridSplitElement and override the CreateTableElement() return your class from 1. 3. Inherit from PropertyGridElement and override the CreateSplitElement() return your class from 2. 4. Inherit from RadPropertyGrid and override the CreatePropertyGridElement() return your class from 3.
RadPropertyGrid should not invalidate the properties when the help bar is resized.
RadPropertyGrid - when default value attribute is Color.Empty, the items is styled with bold font and "Modified" icon. Workaround: Use ItemFormatting event to style the item correctly. Code to reproduce: public class TestObj { private Color someColor; public TestObj() { this.someColor = Color.Empty; } [DefaultValue(typeof(Color), "Empty")] public Color SomeColor { get { return someColor; } set { someColor = value; } } } TestObj newObj = new TestObj(); this.radPropertyGrid1.SelectedObject = newObj;
To reproduce: - Create a PropertyGrid and initialize it like this: PropertyStoreItem checkboxItem = new PropertyStoreItem(typeof(bool), "Checkbox", true); _store = new RadPropertyStore(); _store.Add(checkboxItem); this.radPropertyGrid1.SelectedObject = _store; -change the store item first to null then to false Workaround: -Before you set the item value to false set it to true first like this: item.Value = null; //set first to true then to false item.Value = true; item.Value = false;
When the TypeConverter of a property cannot convert from string the text box editor that opens for this property should be read only.
When you change the CurrentUICulture the string "(none)" in the PropertyGridItemElement is localized but when you open the editor, the text is still "(none)".
To reproduce, use the following class: public class NullableDummy { public bool? Bool { get; set; } public byte? Byte { get; set; } public char? Char { get; set; } public decimal? Decimal { get; set; } public float? Float { get; set; } public int? Int { get; set; } public long? Long { get; set; } public sbyte? Sbyte { get; set; } public short? Short { get; set; } public string String { get; set; } public ulong? Ulong { get; set; } public ushort? Ushort{ get; set; } } And set it as a selected object of the property grid: NullableDummy dummy = new NullableDummy(); this.propertyGrid.SelectedObject = dummy; Change the Byte Property you will see that the value is not being set.
To reproduce: List<PropertyStoreItem> propertyStoreItems = new List<PropertyStoreItem>(); propertyStoreItems.Add(modelItem); RadPropertyStore store = new RadPropertyStore(); store.AddRange(propertyStoreItems); Workaround: Iterate the collection and use the Add method foreach (var item in propertyStoreItems) { store.Add(item); }
To reproduce - create a form with a RadPropertyGrid. - set ToolbarVisible to true - add some properties, but not enough to cause the scrollbar to appear. - start and click on the sort button: the sort is changed, but the scroll bar became visible even if it is not needed. Workaround: public class MyPropGrid : RadPropertyGrid { protected override PropertyGridElement CreatePropertyGridElement() { return new MyPropGridElement(); } public override string ThemeClassName { get { return typeof(RadPropertyGrid).FullName; } set { } } } public class MyPropGridElement : PropertyGridElement { protected override PropertyGridSplitElement CreateSplitElement() { return new MyPropGridSplitElement(); } protected override Type ThemeEffectiveType { get { return typeof(PropertyGridElement); } } } public class MyPropGridSplitElement : PropertyGridSplitElement { protected override PropertyGridTableElement CreateTableElement() { return new MyPropGridTableElemnet(); } protected override Type ThemeEffectiveType { get { return typeof(PropertyGridSplitElement); } } } public class MyPropGridTableElemnet : PropertyGridTableElement { protected override void UpdateScrollers(UpdateActions updateAction) { this.Scroller.UpdateScrollRange(); } protected override Type ThemeEffectiveType { get { return typeof(PropertyGridTableElement); } } }
Pressing Ctrl + Enter should create a new row in the editor instead of closing it. WORKAROUND: Replace the default editor with the following one in the EditorRequired event: class MyPropertyGridTextBoxEditor : PropertyGridTextBoxEditor { protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e) { if (e.Modifiers == System.Windows.Forms.Keys.Control && e.KeyCode == System.Windows.Forms.Keys.Enter) { return; } base.OnKeyDown(e); } }
Steps to reproduce: 1. Add a RadPropertyGrid to a form 2. Set the SelectedObject property to an object with numeric property 3. Open the numeric property for edit and click the arrow buttons to change the value. 4. Click on another control that can take focus e.g. the form control box buttons You will see that the editor remains open.
To reproduce: Open VisualStyleBuilder and navigate to RadGanttView -> RadGanttViewElement and try to edit the Value of the BackgroundImageLayout and ImageLayout properties. Workaround: Edit the value manually, as a string
To reproduce: Add a RadPropertyGrid to a form. Use the following code: this.radPropertyGrid1.SortOrder = System.Windows.Forms.SortOrder.Ascending; this.radPropertyGrid1.PropertySort = System.Windows.Forms.PropertySort.Categorized; As a workaround you can manually scroll to the top before performing a filtering operation: public class MyPropertyGrid : RadPropertyGrid { protected override PropertyGridElement CreatePropertyGridElement() { return new MyPropertyGridElement(); } } public class MyPropertyGridElement : PropertyGridElement { protected override PropertyGridToolbarElement CreateToolbarElement() { return new MyPropertyGridToolbarElement(); } protected override Type ThemeEffectiveType { get { return typeof(PropertyGridElement); } } } public class MyPropertyGridToolbarElement : PropertyGridToolbarElement { protected override void ExecuteSearch() { this.PropertyGridElement.PropertyTableElement.Scroller.Scrollbar.Value = 0; base.ExecuteSearch(); } }
To reproduce: 1. Add a RadPropertyGrid and use the following code: public partial class NewTestWindow : Form { public NewTestWindow() { InitializeComponent(); PropertyGridData data = new PropertyGridData(); (data as INotifyPropertyChanged).PropertyChanged += NewTestWindow_PropertyChanged; ppgItems.SelectedObject = data; Type type = ppgItems.SelectedObject.GetType(); MemberInfo[] members = type.GetMembers(); foreach (MemberInfo m in members) { Attribute[] attributes = Attribute.GetCustomAttributes(m); foreach (Attribute attr in attributes) { if (attr is BrowsableCondition) { BrowsableCondition condition = attr as BrowsableCondition; PropertyGridItem gridItem = ppgItems.Items[m.Name]; gridItem.Visible = false; } } } } private void NewTestWindow_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (ppgItems.SelectedObject != null) { PropertyInfo enableProperty = ppgItems.SelectedObject.GetType().GetProperty(e.PropertyName); bool? value = enableProperty.GetValue(ppgItems.SelectedObject, null) as bool?; if (value.HasValue) { Type type = ppgItems.SelectedObject.GetType(); MemberInfo[] members = type.GetMembers(); foreach (MemberInfo m in members) { Attribute[] attributes = Attribute.GetCustomAttributes(m); foreach (Attribute attr in attributes) { if (attr is BrowsableCondition) { BrowsableCondition condition = attr as BrowsableCondition; PropertyGridItem gridItem = ppgItems.Items[m.Name]; gridItem.Visible = value.Value; } } } } } ppgItems.PropertyGridElement.PropertyTableElement.Update(PropertyGridTableElement.UpdateActions.Resume); } } public class PropertyGridData : INotifyPropertyChanged { public string Item { get; set; } [Browsable(true)] [BrowsableCondition("Enable")] public bool A0 { get; set; } [Browsable(true)] [BrowsableCondition("Enable")] public bool A1 { get; set; } [Browsable(true)] [BrowsableCondition("Enable")] public bool A2 { get; set; } [Browsable(true)] [BrowsableCondition("Enable")] public bool A3 { get; set; } [Browsable(true)] [BrowsableCondition("Enable")] public bool A4 { get; set; } [Browsable(true)] [BrowsableCondition("Enable")] public bool A5 { get; set; } public string Anything { get; set; } private bool _enable; public bool Enable { get { return _enable; } set { _enable = value; RaisePropertyChanged("Enable"); } } public event PropertyChangedEventHandler PropertyChanged; public void RaisePropertyChanged(string propertyName) { if (this.PropertyChanged != null) this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public class BrowsableCondition : Attribute { public BrowsableCondition(string propertyName) { this.PropertyName = propertyName; } public string PropertyName { get; set; } } 2. Run the application. The RadPropertyGrid has a checkbox with Enable property. When selected, other properties are displayed (A0, A1, A2, A3, A4, A5). When the user marks some of these checkboxes that were hidden and then uncheck the Enable property, the PropertyGridItemElement component throws a System.NullReferenceException.
Workaround: class MyRadPropertyGrid : RadPropertyGrid { protected override void WndProc(ref Message m) { switch (m.Msg) { case 0x7b: Point point; int x = Telerik.WinControls.NativeMethods.Util.SignedLOWORD(m.LParam); int y = Telerik.WinControls.NativeMethods.Util.SignedHIWORD(m.LParam); if (((int)((long)m.LParam)) == -1) { point = new Point(this.Width / 2, this.Height / 2); } else { point = this.PointToClient(new Point(x, y)); } this.PropertyGridElement.PropertyTableElement.ProcessContextMenu(point); return; } base.WndProc(ref m); } }