Currently users can only specify a UITypeEditor. They should be able to specify which BaseInputEditor to be used for a given property when they edit it: [Editor(typeof(PropertyGridBrowseEditor), typeof(BaseInputEditor)] public string FilePath { get; set; }
Currently RadPropertyGrid does not handle the GetStandardValues method.
To reproduce: public Form1() { InitializeComponent(); PropertyStoreItem intItem = new PropertyStoreItem(typeof(int), "Integer", 1); PropertyStoreItem floatItem = new PropertyStoreItem(typeof(float), "Float", 1f, "Property storing a floating point value."); PropertyStoreItem stringItem = new PropertyStoreItem(typeof(string), "String", "telerik", "Property storing a string value", "Telerik"); PropertyStoreItem dockItem = new PropertyStoreItem(typeof(DockStyle), "Dock", DockStyle.Top, "Property containing DockStyle value", "Layout", false); RadPropertyStore store = new RadPropertyStore(); store.Add(intItem); store.Add(floatItem); store.Add(stringItem); store.Add(dockItem); this.radPropertyGrid1.SelectedObject = store; } private void radButton1_Click(object sender, EventArgs e) { PropertyStoreItem intItem = new PropertyStoreItem(typeof(int), "Integer111", 1); PropertyStoreItem floatItem = new PropertyStoreItem(typeof(float), "Float111", 1f, "Property storing a floating point value.111"); PropertyStoreItem stringItem = new PropertyStoreItem(typeof(string), "String111", "telerik", "Property storing a string value", "Telerik111"); PropertyStoreItem dockItem = new PropertyStoreItem(typeof(DockStyle), "Dock111", DockStyle.Top, "Property containing DockStyle value", "Layout111", false); RadPropertyStore store = new RadPropertyStore(); store.Add(intItem); store.Add(floatItem); store.Add(stringItem); store.Add(dockItem); this.radPropertyGrid1.SelectedObject = store; } WORKAOUND: radPropertyGrid1.PropertyGridElement.SplitElement.HelpElement.TitleText = ""; radPropertyGrid1.PropertyGridElement.SplitElement.HelpElement.ContentText = "";
ADD. RadPropertyGrid - add custom grouping functionality
1. Drag a new RadPropertyGrid to a form. 2. Set the selected object property to any object 3. Add an event handler for the PropertyValueChanged event and add code in it that sets the same object as selected object of the property grid. 4. You will get a NullReferenceException
To reproduce: Follow this article http://www.telerik.com/help/winforms/propertygrid-features-custom-grouping.html . You will notice that the CustomGrouping event will not fire.
Add a RadPropertyGrid and change its Dock property to Fill. Use the following code: public partial class Form1 : Form { RadPropertyStore _store; public Form1() { InitializeComponent(); this.radPropertyGrid1.CreateItemElement += new CreatePropertyGridItemElementEventHandler(this.onCreateItemElement); _store = new RadPropertyStore(); PropertyStoreItem barItem = new PropertyStoreItem(typeof(Int32), "TrackBar", 25); _store.Add(barItem); PropertyStoreItem sec = new PropertyStoreItem(typeof(bool), "Checkr", true); _store.Add(sec); this.radPropertyGrid1.SelectedObject = _store; } private void onCreateItemElement(object sender, CreatePropertyGridItemElementEventArgs e) { PropertyGridItem item = e.Item as PropertyGridItem; if (item != null) { if (item.Name == "TrackBar") { e.ItemElementType = typeof(TrackBarPropertyGridItem); } } } } public class TrackBarPropertyGridItem : PropertyGridItemElement { protected override PropertyGridValueElement CreatePropertyGridValueElement() { return new CustomPropertyGridValueElement(); } } public class CustomPropertyGridValueElement : PropertyGridValueElement { RadTrackBarElement _trackbar; public RadTrackBarElement Trackbar { get { return this._trackbar; } } protected override void CreateChildElements() { base.CreateChildElements(); _trackbar = new RadTrackBarElement(); _trackbar.Minimum = 0; _trackbar.Maximum = 100; this.DrawText = false; this.Children.Add(_trackbar); } } When resizing the form, the applications hangs. Workaround: /// <summary> /// Track bar property grid element /// </summary> public class TrackBarPropertyGridItem : PropertyGridItemElement { class MyTrackBarElement : RadTrackBarElement { protected override void OnNotifyPropertyChanged(string propertyName) { if (propertyName == "TickOffSet" || propertyName == "ThumbSize") { this.BodyElement.ScaleContainerElement.InvalidateMeasure(); this.BodyElement.IndicatorContainerElement.InvalidateMeasure(); return; } base.OnNotifyPropertyChanged(propertyName); } protected override Type ThemeEffectiveType { get { return typeof(RadTrackBarElement); } } } /// <summary> /// The trackbar element to be displayed in the cell /// </summary> private RadTrackBarElement _trackbar; /// <summary> /// Accessor to the track bar element /// </summary> public RadTrackBarElement Trackbar { get { return _trackbar; } } /// <summary> /// Create child elements of the propertyGridItem /// </summary> protected override void CreateChildElements() { base.CreateChildElements(); _trackbar = new MyTrackBarElement(); _trackbar.Minimum = 0; _trackbar.Maximum = 100; _trackbar.ShowTicks = false; this.ValueElement.DrawText = false; this.ValueElement.Children.Add(this._trackbar); } /// <summary> /// Synchronise the value with property grid item /// </summary> public override void Synchronize() { base.Synchronize(); PropertyGridItem item = this.Data as PropertyGridItem; this._trackbar.Value = (int)item.Value; } /// <summary> /// Add editor override /// </summary> /// <param name="editor">input editor</param> public override void AddEditor(IInputEditor editor) { } /// <summary> /// Remove editor override /// </summary> /// <param name="editor">input editor</param> public override void RemoveEditor(IInputEditor editor) { } /// <summary> /// Check if the item is comptable with trackbar editor /// </summary> /// <param name="data">item to check</param> /// <param name="context">context</param> /// <returns>true if compatible, false otherwise</returns> public override bool IsCompatible(PropertyGridItemBase data, object context) { PropertyGridItem item = data as PropertyGridItem; return (item != null && item.PropertyType == typeof(int)); } /// <summary> /// Get the type of the property grid element /// </summary> protected override Type ThemeEffectiveType { get { return typeof(PropertyGridItemElement); } }
Steps to reproduce. 1. Drag a RadPropertyGrid to a form. 2. Set the selected object to a button for example. 3. Set the System.Threading.Thread.CurrentThread.CurrentUICulture to bg-BG for example 4. Run the project and try to edit the Size property. You will see that it is displayed in the format X;Y, but you have to enter string in the X,Y format otherwise you get an exception.
Steps to reproduce: 1. Add a RadPropertyGrid to a form. 2. Set the SelectedObjects property to a array of one object that has a property decorated with the ReadOnly attribute. Run the project and you will see that the read only property is not displayed.
If one sets an empty RadPropertyStore to the SelectedObject property of a RadPropertyGrid and then adds items with a RadSortOrder attribute the items will still be sorted by their name. WORKAROUNDS: 1. Populate the store before you set it to the property grid. 2. Add a dummy item to the store before you set it to the property grid and then remove it: RadPropertyStore store = new RadPropertyStore(); store.Add(typeof(bool), "dummy", false); this.radPropertyGrid1.SelectedObject = store; store.RemoveAt(0); 3. After you add the first item to the store call the following method: this.radPropertyGrid1.PropertyGridElement.PropertyTableElement.ListSource.CollectionView.EnsureDescriptors();
When the SelectedObject contains sub-properties and a user expands a property the CreateItem event is not fired for sub items.
When a property has a TypeConverter and a UITypeEditor attributes the PropertyGridUITypeEditor calls the TypeConverter methods with the context parameter equal to null.
To reproduce: public Form1() { InitializeComponent(); this.radPropertyGrid1.SelectedObject = this; this.radPropertyGrid1.ContextMenuOpening += radPropertyGrid1_ContextMenuOpening; } private void radPropertyGrid1_ContextMenuOpening(object sender, Telerik.WinControls.UI.PropertyGridContextMenuOpeningEventArgs e) { foreach (RadItem item in e.Menu.Items) { if (item.Text == "Sort") { item.Visibility = ElementVisibility.Collapsed; item.PropertyChanged += item_PropertyChanged; } } } Workaround: private void radPropertyGrid1_ContextMenuOpening(object sender, Telerik.WinControls.UI.PropertyGridContextMenuOpeningEventArgs e) { RadItem item = null; for (int i = 0; i < e.Menu.Items.Count; i++) { item = e.Menu.Items[i]; if (item.Text=="Sort") { e.Menu.Items.Remove(item); } } }
The incorrect behavior is also observed if the SelectedObject is changed. How to reproduce: public partial class RadForm1 : RadForm { public RadForm1() { this.InitializeComponent(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.radPropertyGrid1.EnableSorting = true; this.radPropertyGrid1.SelectedObject = new TestObject(); foreach (var item in this.radPropertyGrid1.Items) { if (item.Name == "A") { item.SortOrder = 2; } else if (item.Name == "B") { item.SortOrder = 1; } else { item.SortOrder = 0; } } this.radPropertyGrid1.PropertySort = PropertySort.NoSort; } } public class TestObject { public int A { get; set; } public int C { get; set; } public int B { get; set; } } Workaround: 1. Use attributes in the model class: public class TestObject { [RadSortOrder(2)] public int A { get; set; } [RadSortOrder(0)] public int C { get; set; } [RadSortOrder(1)] public int B { get; set; } } 2. Alternatively, toggle the PropertySort property in the Shown event of the form: public partial class RadForm1 : RadForm { public RadForm1() { this.InitializeComponent(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.radPropertyGrid1.EnableSorting = true; this.radPropertyGrid1.SelectedObject = new TestObject(); foreach (var item in this.radPropertyGrid1.Items) { if (item.Name == "A") { item.SortOrder = 2; } else if (item.Name == "B") { item.SortOrder = 1; } else { item.SortOrder = 0; } } this.radPropertyGrid1.PropertySort = PropertySort.NoSort; } protected override void OnShown(EventArgs e) { base.OnShown(e); this.radPropertyGrid1.PropertySort = PropertySort.Alphabetical; this.radPropertyGrid1.PropertySort = PropertySort.NoSort; } } public class TestObject { public int A { get; set; } public int C { get; set; } public int B { get; set; } }
To reproduce: - Add a property grid to a blank form set the selected object the the same form. - Group the items and click several times to expand collapse the groups or items. - you will notice that some of expanded/collapsed groups icon is in wrong state (same applies for the +/- sign of the properties).
Workaround: public class CustomPropertyGrid : RadPropertyGrid { public override string ThemeClassName { get { return typeof(RadPropertyGrid).FullName; } } protected override PropertyGridElement CreatePropertyGridElement() { return new CustomPropertyGridElement(); } } public class CustomPropertyGridElement : PropertyGridElement { protected override Type ThemeEffectiveType { get { return typeof(PropertyGridElement); } } protected override PropertyGridSplitElement CreateSplitElement() { return new CustomPropertyGridSplitElement(); } } public class CustomPropertyGridSplitElement : PropertyGridSplitElement { protected override Type ThemeEffectiveType { get { return typeof(PropertyGridSplitElement); } } protected override PropertyGridTableElement CreateTableElement() { return new CustomPropertyGridTableElement(); } } public class CustomPropertyGridTableElement:PropertyGridTableElement { protected override Type ThemeEffectiveType { get { return typeof(PropertyGridTableElement); } } public override bool ProcessKeyDown(KeyEventArgs e) { if (e.KeyData == Keys.Enter && ((PropertyGridItem)this.SelectedGridItem).PropertyType == typeof(bool)) { PropertyGridItem item = this.SelectedGridItem as PropertyGridItem; item.Value = !(bool)item.Value; return true; } return base.ProcessKeyDown(e); } }
To reproduce: Use the following code snippet and perform the step illustrating on the attached gif file. Note that this undesired behavior appears randomly. Partial Public Class Form1 Inherits Telerik.WinControls.UI.RadForm Public Sub New() InitializeComponent() radPropertyGrid1.PropertySort = Windows.Forms.PropertySort.Categorized radPropertyGrid1.SortOrder = Windows.Forms.SortOrder.None Dim metaDocItem As New PropertyStoreItem(GetType(String), "Document ID", "16.0", "Document ID Number", "Meta Data", True) Dim fileInfoItem As New PropertyStoreItem(GetType(FileInfo), "File Info", New FileInfo("sample file path", "file name path"), _ "", "Meta Data", True) fileInfoItem.Attributes.Add(New TypeConverterAttribute(GetType(MyDataConverter))) Dim stringItem As New PropertyStoreItem(GetType(String), "String", "telerik", "Property storing a string value", "Meta Data", True) Dim dockItem As New PropertyStoreItem(GetType(DockStyle), "Dock", DockStyle.Top, "Property containing DockStyle value", "Meta Data", True) Dim store As New RadPropertyStore store.Add(metaDocItem) store.Add(fileInfoItem) store.Add(stringItem) store.Add(dockItem) Me.RadPropertyGrid1.SelectedObject = store End Sub End Class Public Class FileInfo Private _filePath As String Private _fileName As String Public Sub New(filePath As String, fileName As String) Me._filePath = filePath Me._fileName = fileName End Sub Public ReadOnly Property FilePath() As String Get Return _filePath End Get End Property Public ReadOnly Property FileName() As String Get Return _fileName End Get End Property End Class Public Class MyDataConverter Inherits ExpandableObjectConverter Public Overrides Function CanConvertTo(context As ITypeDescriptorContext, destinationType As Type) As Boolean If destinationType = GetType(String) Then Return True End If Return MyBase.CanConvertTo(context, destinationType) End Function Public Overrides Function ConvertTo(context As ITypeDescriptorContext, culture As System.Globalization.CultureInfo, _ value As Object, destinationType As Type) As Object If destinationType <> GetType(String) Then Return MyBase.ConvertTo(context, culture, value, destinationType) End If Return String.Empty End Function End Class Workaround: add a RadSortOrderAttribute to each PropertyStoreItem and leave the default SortOrder = Windows.Forms.SortOrder.Ascending
To reproduce: use a class with more than 100 properties for the RadPropertyGrid.SelectedObject. On RadButton.Click event set the RradPropertyGrid.PropertySort to PropertySort.CategorizedAlphabetical.
To reproduce: use the following code: Items _items = new Items(); public Form1() { InitializeComponent(); radPropertyGrid1.SelectedObject = _items; } class Items { [Description("A Bool Property")] public bool IsEnabled { get { return _isEnabled; } set { _isEnabled = value; RadMessageBox.Show("IsEnabled"); } } private bool _isEnabled; [Description("A String Property")] public string Name { get { return _name; } set { _name = value; RadMessageBox.Show("Name"); } } private string _name ; } Steps to perform: 1. Change the "Name" property and leave the editor active. 2. Click on the check box to change the "IsEnabled" property. As a result you will notice that the "IsEnabled" setter is called before the "Name" setter. Workaround: Items _items = new Items(); public Form1() { InitializeComponent(); this.radPropertyGrid1.CreateItemElement += radPropertyGrid1_CreateItemElement; radPropertyGrid1.SelectedObject = _items; } private void radPropertyGrid1_CreateItemElement(object sender, CreatePropertyGridItemElementEventArgs e) { if (e.ItemElementType == typeof(PropertyGridCheckBoxItemElement)) { e.ItemElementType = typeof(CustomPropertyGridCheckBoxItemElement); } } public class CustomPropertyGridCheckBoxItemElement : PropertyGridCheckBoxItemElement { public CustomPropertyGridCheckBoxItemElement() { this.CheckBoxElement.ToggleStateChanging += CheckBoxElement_ToggleStateChanging; } private void CheckBoxElement_ToggleStateChanging(object sender, StateChangingEventArgs args) { if (this.PropertyTableElement.ActiveEditor != null && this.PropertyTableElement.SelectedGridItem != this.Data) { this.PropertyTableElement.EndEdit(); } } protected override void DisposeManagedResources() { this.CheckBoxElement.ToggleStateChanging -= CheckBoxElement_ToggleStateChanging; base.DisposeManagedResources(); } }