void propertyGridControl1_CustomPropertyDescriptors(object sender, CustomPropertyDescriptorsEventArgs e) { if (e.Source == propertyStore) { PropertyDescriptorCollection rootProperties = new PropertyDescriptorCollection(null); foreach (PropertyDescriptor pd in propertyStore) { rootProperties.Add(pd); } e.Properties = rootProperties; } }
void _PropertyGrid_CustomPropertyDescriptors(object sender, CustomPropertyDescriptorsEventArgs e) { if ((sender as PropertyGridControl).SelectedObject == e.Source) { PropertyDescriptorCollection properties = e.Properties; ArrayList list = new ArrayList(properties); list.AddRange(_UnboundRows); PropertyDescriptor[] result = new PropertyDescriptor[list.Count]; list.ToArray().CopyTo(result, 0); e.Properties = new PropertyDescriptorCollection(result); } }
void propertyGridControl1_CustomPropertyDescriptors(object sender, CustomPropertyDescriptorsEventArgs e) { // Provide properties to be displayed at the root level if (e.Context.PropertyDescriptor == null) { PropertyDescriptorCollection filteredCollection = new PropertyDescriptorCollection(null); AddIfPropertyExist(e.Properties, filteredCollection, "Dock"); AddIfPropertyExist(e.Properties, filteredCollection, "Size"); AddIfPropertyExist(e.Properties, filteredCollection, "Location"); AddIfPropertyExist(e.Properties, filteredCollection, "NonexistentProperty"); e.Properties = filteredCollection; } //Provide nested properties for the Size property if (e.Context.PropertyDescriptor != null && e.Context.PropertyDescriptor.Name == "Size") { PropertyDescriptorCollection filteredCollection = new PropertyDescriptorCollection(null); AddIfPropertyExist(e.Properties, filteredCollection, "Height"); e.Properties = filteredCollection; } }
private void propertyGridControl_CustomPropertyDescriptors(object sender, CustomPropertyDescriptorsEventArgs e) { // Provide properties to be displayed at the root level if (e.Context.PropertyDescriptor == null) { if (this.allowCustomSorting) { PropertyDescriptorCollection asc = e.Properties.Sort( ); string[] keys = new string[asc.Count]; for (int i = 0; i < asc.Count; i++) { keys[i] = asc[i].Name; } Array.Reverse(keys); e.Properties = e.Properties.Sort(keys); } // #region --- Filter Properties --- //PropertyDescriptorCollection filteredCollection = new PropertyDescriptorCollection( null ); //this.AddIfPropertyExist( e.Properties, filteredCollection, "Dock" ); //this.AddIfPropertyExist( e.Properties, filteredCollection, "Size" ); //this.AddIfPropertyExist( e.Properties, filteredCollection, "Location ); //this.AddIfPropertyExist( e.Properties, filteredCollection, "NonexistentProperty" ); //e.Properties = filteredCollection; #endregion } #region --- Filter Properties --- //Provide nested properties for the Size property //if( e.Context.PropertyDescriptor != null && e.Context.PropertyDescriptor.Name == nameof( Size ) ) //{ // PropertyDescriptorCollection filteredCollection = new PropertyDescriptorCollection( null ); // this.AddIfPropertyExist( e.Properties, filteredCollection, nameof( Height ) ); // e.Properties = filteredCollection; //} #endregion }