To reproduce: public Form1() { InitializeComponent(); this.radPropertyGrid1.Size = new System.Drawing.Size(272, 135); PropertyStoreItem intItem = new PropertyStoreItem(typeof(int), "Integer", 1); PropertyStoreItem showTrend = new PropertyStoreItem(typeof(bool), "ShowTrend", 0); PropertyStoreItem trendItem1 = new PropertyStoreItem(typeof(int), "TrendTypes", 0); // Case of Re-loading the previously Saved Trend Type 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(showTrend); store.Add(trendItem1); store.Add(floatItem); store.Add(stringItem); store.Add(dockItem); this.radPropertyGrid1.SelectedObject = store; radPropertyGrid1.Items["TrendTypes"].Visible = false; this.radPropertyGrid1.PropertyValueChanged += radPropertyGrid1_ValueChanged; } private void radPropertyGrid1_ValueChanged(object sender, PropertyGridItemValueChangedEventArgs e) { PropertyGridItem current = (PropertyGridItem)e.Item; if (current.Name == "ShowTrend") { bool val = Convert.ToBoolean(current.Value); radPropertyGrid1.Items["TrendTypes"].Visible = val; } } - There is no scrollbar when the item is shown. Workaround: radPropertyGrid1.PropertyGridElement.PropertyTableElement.Update(PropertyGridTableElement.UpdateActions.ExpandedChanged);
To reproduce: please refer to the attached gif file. The error is not reproduced each time with the Demo application. Sometimes an unhandled exception dialog appears and sometimes the application becomes unresponsive and you can not close the application with upper right X, the options to the right does not respond, you can not change demo using the list on the left. Selecting "Settings" in Property Grid section and then clicking on a boolean property (left column), scrolling using the mouse wheel, then selecting another property (with PropertyGridDropDownListEditor) or clicking around in the application (even outside of the property grid form). Workaround: this.radPropertyGrid1.EditorRequired += radPropertyGrid1_EditorRequired; private void radPropertyGrid1_EditorRequired(object sender, PropertyGridEditorRequiredEventArgs e) { if (e.EditorType == typeof(PropertyGridDropDownListEditor)) { e.Editor = new CustomPropertyGridDropDownListEditor(); } } public class CustomPropertyGridDropDownListEditor : PropertyGridDropDownListEditor { public override object Value { get { PropertyGridItemElement element = this.OwnerElement as PropertyGridItemElement; PropertyGridItem item = element.Data as PropertyGridItem; if (item == null) { return null; } return base.Value; } set { base.Value = value; } } }
To reproduce: public Form1() { InitializeComponent(); this.radPropertyGrid1.SelectedObject = new Item(123,"Item123",DateTime.Now.AddDays(20)); this.radPropertyGrid1.EditorInitialized += radPropertyGrid1_EditorInitialized; } private void radPropertyGrid1_EditorInitialized(object sender, Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs e) { PropertyGridDateTimeEditor propertyGridDateTimeEditor = e.Editor as PropertyGridDateTimeEditor; if (propertyGridDateTimeEditor != null) { BaseDateTimeEditorElement dateTimeEditorElement = propertyGridDateTimeEditor.EditorElement as BaseDateTimeEditorElement; if (dateTimeEditorElement != null) { dateTimeEditorElement.Format = DateTimePickerFormat.Long; dateTimeEditorElement.ShowTimePicker = true; var radDateTimePickerCalendar = dateTimeEditorElement.CurrentBehavior as RadDateTimePickerCalendar; if (radDateTimePickerCalendar != null) { radDateTimePickerCalendar.DropDownMinSize = new System.Drawing.Size(600, 400); } } } } public class Item { public int Id { get; set; } public string Name { get; set; } public DateTime Date { get; set; } public Item(int id, string name, DateTime date) { this.Id = id; this.Name = name; this.Date = date; } } Workaround: private void radPropertyGrid1_EditorInitialized(object sender, Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs e) { PropertyGridDateTimeEditor propertyGridDateTimeEditor = e.Editor as PropertyGridDateTimeEditor; if (propertyGridDateTimeEditor != null) { BaseDateTimeEditorElement dateTimeEditorElement = propertyGridDateTimeEditor.EditorElement as BaseDateTimeEditorElement; if (dateTimeEditorElement != null) { dateTimeEditorElement.Format = DateTimePickerFormat.Long; dateTimeEditorElement.ShowTimePicker = true; var radDateTimePickerCalendar = dateTimeEditorElement.CurrentBehavior as RadDateTimePickerCalendar; if (radDateTimePickerCalendar != null) { radDateTimePickerCalendar.PopupControl.PopupOpened-=PopupControl_PopupOpened; radDateTimePickerCalendar.PopupControl.PopupOpened+=PopupControl_PopupOpened; } } } } private void PopupControl_PopupOpened(object sender, EventArgs args) { RadDateTimePickerDropDown dropdown = sender as RadDateTimePickerDropDown; dropdown.MinimumSize = new Size(600, 300); }
To reproduce: subscribe to the RadPropertyGrid.PropertyValidating event and apply ErrorMessage in some cases. If the validation fails, the error indicator is not visible in Windows8, VisualStudio2012Dark, Aqua. However, the error message is displayed as expected. Workaround: assign an image for the ErrorIndicator private void radPropertyGrid1_ItemFormatting(object sender, PropertyGridItemFormattingEventArgs e) { PropertyGridItemElement itemElement = e.VisualElement as PropertyGridItemElement; if (itemElement != null) { ((PropertyGridTextElement)itemElement.TextElement).ErrorIndicator.Image = Properties.Resources.error; } }
Until the new feature is officially released please use the implementation in the attached project.
To reproduce: use the following code snippet and refer to the attached gif file. public Form1() { InitializeComponent(); this.radPropertyGrid1.SelectedObject = this; this.radPropertyGrid1.RightToLeft = System.Windows.Forms.RightToLeft.Yes; } Workaround: public Form1() { InitializeComponent(); this.radPropertyGrid1.CreateItemElement += radPropertyGrid1_CreateItemElement; this.radPropertyGrid1.SelectedObject = this; this.radPropertyGrid1.RightToLeft = System.Windows.Forms.RightToLeft.Yes; } private void radPropertyGrid1_CreateItemElement(object sender, CreatePropertyGridItemElementEventArgs e) { if (e.ItemElementType == typeof(PropertyGridItemElement)) { e.ItemElementType = typeof(CustomPropertyGridItemElement); } } public class CustomPropertyGridItemElement : PropertyGridItemElement { private bool isResizing; private Point downLocation; private int downWidth; protected override Type ThemeEffectiveType { get { return typeof(PropertyGridItemElement); } } private const int resizePointerOffset = 3; public override bool IsInResizeLocation(Point location) { return (location.X >= this.ControlBoundingRectangle.X + this.PropertyTableElement.ValueColumnWidth - resizePointerOffset && location.X <= this.ControlBoundingRectangle.X + this.PropertyTableElement.ValueColumnWidth + resizePointerOffset); } protected override void OnMouseDown(MouseEventArgs e) { if (IsInResizeLocation(e.Location)) { if (this.PropertyTableElement.IsEditing) { this.PropertyTableElement.EndEdit(); } this.Capture = true; this.isResizing = true; this.downLocation = e.Location; this.downWidth = this.PropertyTableElement.ValueColumnWidth; } base.OnMouseDown(e); } protected override void OnMouseMove(MouseEventArgs e) { if (this.isResizing) { int delta = e.Location.X - downLocation.X; if (this.RightToLeft) { delta *= -1; } this.PropertyTableElement.ValueColumnWidth = downWidth - delta; return; } if (this.IsInResizeLocation(e.Location)) { this.ElementTree.Control.Cursor = Cursors.VSplit; } else { this.ElementTree.Control.Cursor = Cursors.Default; } base.OnMouseMove(e); } protected override void OnMouseUp(MouseEventArgs e) { if (this.isResizing) { this.isResizing = false; this.Capture = false; } base.OnMouseUp(e); } }
To reproduce: use the following code snippet and refer to the attached gif file: public Form1() { InitializeComponent(); this.radPropertyGrid1.SelectedObject = this; } private void radButton1_Click(object sender, EventArgs e) { ThemeResolutionService.ApplicationThemeName = "VisualStudio2012Dark"; } private void radButton2_Click(object sender, EventArgs e) { ThemeResolutionService.ApplicationThemeName = "ControlDefault"; } Workaround: private void radPropertyGrid1_EditorInitialized(object sender, PropertyGridItemEditorInitializedEventArgs e) { PropertyGridTextBoxEditor editor = e.Editor as PropertyGridTextBoxEditor; if (editor != null) { BaseTextBoxEditorElement el = editor.EditorElement as BaseTextBoxEditorElement; if (el != null) { el.BackColor = Color.Black; } } }
To reproduce: PropertyStoreItem prop1 = new PropertyStoreItem(typeof(DateTime), "Date", DateTime.Now); PropertyStoreItem prop2 = new PropertyStoreItem(typeof(Nullable<DateTime>), "NullableDate", DateTime.Now); PropertyStoreItem prop3 = new PropertyStoreItem(typeof(DateTime?), "Date?", DateTime.Now); RadPropertyStore store = new RadPropertyStore(); store.Add(prop1); store.Add(prop2); store.Add(prop3); this.radPropertyGrid1.SelectedObject = store; Open the editor for one of the properties and press the Clear button in the PropertyGridDateTimeEditor's popup. The value is cleared, but the PropertyValueButtonElement is not displayed. Workaround: specify the initial value as default value for the property: public Form1() { InitializeComponent(); DateTime initialValue = DateTime.Now; PropertyStoreItem prop1 = new PropertyStoreItem(typeof(DateTime), "Date", initialValue); prop1.Attributes.Add(new DefaultValueAttribute(initialValue)); PropertyStoreItem prop2 = new PropertyStoreItem(typeof(Nullable<DateTime>), "NullableDate", initialValue); prop2.Attributes.Add(new DefaultValueAttribute(initialValue)); PropertyStoreItem prop3 = new PropertyStoreItem(typeof(DateTime?), "Date?", initialValue); prop3.Attributes.Add(new DefaultValueAttribute(initialValue)); RadPropertyStore store = new RadPropertyStore(); store.Add(prop1); store.Add(prop2); store.Add(prop3); this.radPropertyGrid1.SelectedObject = store; }
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: 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); } } }
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
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); } }
Workaround: set the RadPropertyGrid.SelectedGridItem property to null before changing the SelectedObject.
To reproduce: 1. Add a RadPropertyGrid and populate it with all of of items by using the following code: this.radPropertyGrid1.SelectedObject = this; 2. Expand two items. 3. Scroll to the bottom. 4. Scroll to the top. 5. If you scroll to the bottom again, you will see a lot of empty space. The attached gif file illustrates better the problem. Workaround: public Form1() { InitializeComponent(); this.radPropertyGrid1.SelectedObject = this; this.radPropertyGrid1.PropertyGridElement.PropertyTableElement.Scroller.Traverser = new CustomPropertyGridTraverser(this.radPropertyGrid1.PropertyGridElement.PropertyTableElement); } public class CustomPropertyGridTraverser : PropertyGridTraverser { public CustomPropertyGridTraverser(PropertyGridTableElement propertyGridElement) : base(propertyGridElement) { } public int Index { get { FieldInfo fi = typeof(PropertyGridTraverser).GetField("index", BindingFlags.NonPublic | BindingFlags.Instance); return int.Parse(fi.GetValue(this).ToString()); } set { FieldInfo fi = typeof(PropertyGridTraverser).GetField("index", BindingFlags.NonPublic | BindingFlags.Instance); fi.SetValue(this, value); } } public int GroupIndex { get { FieldInfo fi = typeof(PropertyGridTraverser).GetField("groupIndex", BindingFlags.NonPublic | BindingFlags.Instance); return int.Parse(fi.GetValue(this).ToString()); } } public PropertyGridTableElement Element { get { FieldInfo fi = typeof(PropertyGridTraverser).GetField("propertyGridElement", BindingFlags.NonPublic | BindingFlags.Instance); return fi.GetValue(this) as PropertyGridTableElement ; } } public PropertyGridItemBase Item { get { FieldInfo fi = typeof(PropertyGridTraverser).GetField("item", BindingFlags.NonPublic | BindingFlags.Instance); return fi.GetValue(this) as PropertyGridItemBase ; } set { FieldInfo fi = typeof(PropertyGridTraverser).GetField("item", BindingFlags.NonPublic | BindingFlags.Instance); fi.SetValue(this, value); } } protected override bool MovePreviousFromDataItem(PropertyGridItemBase currentItem) { if (currentItem.Parent != null && currentItem.Parent.GridItems.Count > 0) { if (this.Index > 0) { PropertyGridItemBase prevItem = currentItem.Parent.GridItems[--this.Index]; if (prevItem.Expandable && (prevItem.Expanded || this.TraverseHirarchy)) { prevItem = this.GetLastChild(prevItem); } this.Item = prevItem; return true; } this.Item = currentItem.Parent; this.Index = -1; if (currentItem.Parent.Parent != null) { this.Index = currentItem.Parent.Parent.GridItems.IndexOf(currentItem.Parent as PropertyGridItem); } else { if (this.Element.CollectionView.Groups.Count == 0) { this.Index = this.Element.CollectionView.IndexOf(currentItem.Parent as PropertyGridItem); } else { this.Index = this.Element.CollectionView.Groups[this.GroupIndex].IndexOf(currentItem.Parent as PropertyGridItem); } } return true; } return base.MovePreviousFromDataItem(currentItem); } }
The PropertyChanged event does not fire when the ValueColumnWidth property is changed.
To reproduce: private void PopulateGrid() { this.radPropertyGrid1.SortOrder = System.Windows.Forms.SortOrder.Ascending; PropertyStoreItem myRadProp; RadPropertyStore myRadProperties = new RadPropertyStore(); for (int i = 0; i <= 6000; i++) { myRadProp = new PropertyStoreItem(typeof(string), "PropName" + i, "Value" + i, "Help" + i, "same"); myRadProperties.Add(myRadProp); } radPropertyGrid1.SelectedObject = myRadProperties; } Workaround: public Form1() { InitializeComponent(); radPropertyGrid1.PropertyGridElement.PropertyTableElement.ListSource.CollectionView.GroupFactory = new MyPropertyGridGroupFactory(this.radPropertyGrid1.PropertyGridElement.PropertyTableElement); this.radPropertyGrid1.SortOrder = System.Windows.Forms.SortOrder.Ascending; PropertyStoreItem myRadProp; RadPropertyStore myRadProperties = new RadPropertyStore(); for (int i = 0; i <= 6000; i++) { myRadProp = new PropertyStoreItem(typeof(string), "PropName" + i, "Value" + i, "Help" + i, "same"); myRadProperties.Add(myRadProp); } this.radPropertyGrid1.PropertyGridElement.PropertyTableElement.ListSource.BeginUpdate(); radPropertyGrid1.SelectedObject = myRadProperties; this.radPropertyGrid1.PropertyGridElement.PropertyTableElement.ListSource.EndUpdate(); } public class MyPropertyGridGroupFactory : IGroupFactory<PropertyGridItem> { private PropertyGridTableElement propertyGridElement; public MyPropertyGridGroupFactory(PropertyGridTableElement propertyGridElement) { this.propertyGridElement = propertyGridElement; } public GroupCollection<PropertyGridItem> CreateCollection(IList<Group<PropertyGridItem>> list) { return new PropertyGridGroupCollection(list); } public Group<PropertyGridItem> CreateGroup(object key, Group<PropertyGridItem> parent, params object[] metaData) { return new MyPropertyGridGroup(key, parent, this.propertyGridElement); } } public class MyPropertyGridGroup : PropertyGridGroup { private List<PropertyGridItem> items; public MyPropertyGridGroup(object key, Group<PropertyGridItem> parent, PropertyGridTableElement propertyGridElement) : base(key, parent, propertyGridElement) { } protected override IList<PropertyGridItem> Items { get { if (this.items == null) { this.items = new List<PropertyGridItem>(); } return this.items; } } }
To reproduce: radPropertyGrid1.SelectedObject = new RadDropDownList(); The Items collection does not have a setter, but one still should be able to add items via the respective editor.