protected virtual bool MoveNextCore() { if (this.item == null) { return(MoveToFirst()); } if (this.item is PropertyGridGroupItem) { PropertyGridGroupItem group = this.item as PropertyGridGroupItem; return(MoveNextFromGroupItem(group)); } else { PropertyGridItem currentItem = this.item as PropertyGridItem; return(MoveNextFromDataItem(currentItem, true, false)); } }
protected virtual bool MovePreviousCore() { if (this.item == null) { return(false); } if (this.item is PropertyGridGroupItem) { PropertyGridGroupItem group = this.item as PropertyGridGroupItem; return(MovePreviousFromGroupItem(group)); } else { PropertyGridItem currentItem = this.item as PropertyGridItem; return(MovePreviousFromDataItem(currentItem)); } }
private void CreateCategories(Hashtable cats) { HtmlContainerControl cc = new HtmlGenericControl("div"); cc.ID = "cats"; Controls.Add(cc); foreach (string cat in cats.Keys) { PropertyGridCategory pgc = new PropertyGridCategory(); pgc.CategoryName = cat; this.categories.Add(pgc); cc.Controls.Add(pgc); Hashtable i = cats[cat] as Hashtable; ArrayList il = new ArrayList(i.Keys); il.Sort(); foreach (string pginame in il) { PropertyGridItem pgi = i[pginame] as PropertyGridItem; proplist.Add(pgi); pgc.Controls.Add(pgi); if (pgi.subitems.Count > 0) { SubItems si = new SubItems(); pgi.Controls.Add(si); foreach (PropertyGridItem spgi in pgi.subitems) { si.Controls.Add(spgi); proplist.Add(spgi); } } } } }
protected virtual void SetPropertyValueCore(object obj, object value) { if (this.descriptor == null) return; object component = obj; if (component is ICustomTypeDescriptor) component = ((ICustomTypeDescriptor) component).GetPropertyOwner(this.descriptor); bool flag = false; PropertyGridItem parent = this.Owner.Parent as PropertyGridItem; if (parent != null) { Type propertyType = parent.PropertyType; flag = propertyType.IsValueType || propertyType.IsArray; } if (component == null) return; this.descriptor.SetValue(component, value); if (!flag) return; parent.Value = obj; }
void radPropertyGrid1_PropertyValidating(object sender, Telerik.WinControls.UI.PropertyValidatingEventArgs e) { PropertyGridItem item = (PropertyGridItem)e.Item; if (e.Item.Name == "Age" && ((decimal)e.NewValue < 18 || (decimal)e.NewValue > 56)) { item.ErrorMessage = "Age must be between 18 and 56!"; e.Cancel = true; } if (e.Item.Name == "Phone") { Regex regex = new Regex("^(\\(?[0-9]{3}\\)?)?\\-?[0-9]{3}\\-?[0-9]{4}$"); if (e.NewValue == null || !regex.IsMatch(e.NewValue.ToString())) { item.ErrorMessage = "This is not a valid phone. Please enter valid phone to continue."; e.Cancel = true; } } if (e.Item.Name == "EMail") { Regex regex = new Regex("^[A-Za-z0-9_\\-\\.]+@(([A-Za-z0-9\\-])+\\.)+([A-Za-z\\-])+$"); if (e.NewValue == null || !regex.IsMatch(e.NewValue.ToString())) { item.ErrorMessage = "This is not a valid email address. Please enter valid email address to continue."; e.Cancel = true; } } if (e.Item.Name == "Country" || e.Item.Name == "City" || e.Item.Name == "Name" || e.Item.Name == "Family") { if (string.IsNullOrEmpty(e.NewValue as string)) { item.ErrorMessage = "Please enter valid data!"; e.Cancel = true; } } }
public ImmutableItemAccessor(PropertyGridItem owner, PropertyDescriptor descriptor) : base(owner, descriptor) { }
public ItemAccessor(PropertyGridItem owner) { this.owner = owner; }
public override bool IsCompatible(PropertyGridItemBase data, object context) { PropertyGridItem item = data as PropertyGridItem; return(item != null && item.PropertyType == typeof(string)); }
public ArrayItemAccessor(PropertyGridItem owner, int index) : base(owner) { this.index = index; }
public PropertyGridSubItem(PropertyDescriptor propertyDescriptor, PropertyGridItem parentitem) : base(propertyDescriptor) { _parentitem = parentitem; }
private PropertyGridSpreadExportRow CreateExportRow( PropertyGridItemBase item, int itemLevel, int currentRowIndex, ref bool skipHiddenChildItems, ref int collapsedParentLevel, ref bool exportChildItemsHidden) { PropertyGridSpreadExportRow gridSpreadExportRow = new PropertyGridSpreadExportRow(); if (!item.Expanded && this.CollapsedItemOption == HiddenOption.DoNotExport) { skipHiddenChildItems = true; collapsedParentLevel = itemLevel; } if (exportChildItemsHidden && collapsedParentLevel >= itemLevel) { exportChildItemsHidden = false; } if (item is PropertyGridItem) { PropertyGridItem propertyGridItem = item as PropertyGridItem; PropertyGridItemElement propertyGridItemElement = (PropertyGridItemElement)null; if (this.ExportVisualSettings) { propertyGridItemElement = this.elementProvider.GetElement((PropertyGridItemBase)propertyGridItem, (object)null) as PropertyGridItemElement; this.propertyGrid.PropertyGridElement.PropertyTableElement.ViewElement.Children.Add((RadElement)propertyGridItemElement); propertyGridItemElement.Attach((PropertyGridItemBase)propertyGridItem, (object)null); } for (int index = 0; index < itemLevel; ++index) { PropertyGridSpreadExportIndentCell exportIndentCell = new PropertyGridSpreadExportIndentCell(); exportIndentCell.Size = new Size(this.ItemIndent, exportChildItemsHidden ? 0 : -1); if (this.ExportVisualSettings) { if (index == 0 && this.isGridGrouped) { if (itemLevel > 1) { this.GetStylesFromVisualCell((PropertyGridSpreadExportCell)exportIndentCell, (LightVisualElement)propertyGridItemElement.HeaderElement); } else { this.GetStylesFromVisualCell((PropertyGridSpreadExportCell)exportIndentCell, (LightVisualElement)propertyGridItemElement.ExpanderElement); } } else { this.GetStylesFromVisualCell((PropertyGridSpreadExportCell)exportIndentCell, (LightVisualElement)propertyGridItemElement.IndentElement); } this.GetBordersFromVisualCell((PropertyGridSpreadExportCell)exportIndentCell, (LightVisualElement)propertyGridItemElement); } this.OnCellFormatting(new PropertyGridSpreadExportCellFormattingEventArgs((PropertyGridSpreadExportCell)exportIndentCell, (PropertyGridItemBase)propertyGridItem, currentRowIndex)); gridSpreadExportRow.Cells.Add((PropertyGridSpreadExportCell)exportIndentCell); } PropertyGridSpreadExportContentCell exportContentCell1 = new PropertyGridSpreadExportContentCell(); exportContentCell1.Text = propertyGridItem.Label; exportContentCell1.ColSpan += this.depthOfTree - propertyGridItem.Level; exportContentCell1.Size = new Size(this.textCellWidth - itemLevel * this.ItemIndent, exportChildItemsHidden ? 0 : -1); gridSpreadExportRow.Cells.Add((PropertyGridSpreadExportCell)exportContentCell1); if (this.ExportVisualSettings) { this.GetStylesFromVisualCell((PropertyGridSpreadExportCell)exportContentCell1, (LightVisualElement)propertyGridItemElement.TextElement); this.GetBordersFromVisualCell((PropertyGridSpreadExportCell)exportContentCell1, (LightVisualElement)propertyGridItemElement); } this.OnCellFormatting(new PropertyGridSpreadExportCellFormattingEventArgs((PropertyGridSpreadExportCell)exportContentCell1, (PropertyGridItemBase)propertyGridItem, currentRowIndex)); PropertyGridSpreadExportContentCell exportContentCell2 = new PropertyGridSpreadExportContentCell(); exportContentCell2.Value = propertyGridItem.Value; exportContentCell2.Text = propertyGridItem.FormattedValue; exportContentCell2.Size = new Size(this.valueCellWidth, exportChildItemsHidden ? 0 : -1); if (this.ExportVisualSettings) { this.GetStylesFromVisualCell((PropertyGridSpreadExportCell)exportContentCell2, (LightVisualElement)propertyGridItemElement.ValueElement); this.GetBordersFromVisualCell((PropertyGridSpreadExportCell)exportContentCell2, (LightVisualElement)propertyGridItemElement); } this.OnCellFormatting(new PropertyGridSpreadExportCellFormattingEventArgs((PropertyGridSpreadExportCell)exportContentCell2, (PropertyGridItemBase)propertyGridItem, currentRowIndex)); gridSpreadExportRow.Cells.Add((PropertyGridSpreadExportCell)exportContentCell2); if (this.ExportDescriptions) { PropertyGridSpreadExportContentCell exportContentCell3 = new PropertyGridSpreadExportContentCell(); exportContentCell3.Text = propertyGridItem.Description; exportContentCell3.Size = new Size((this.textCellWidth + this.valueCellWidth) * 2, exportChildItemsHidden ? 0 : -1); if (this.ExportVisualSettings) { this.GetStylesFromVisualCell((PropertyGridSpreadExportCell)exportContentCell3, (LightVisualElement)propertyGridItemElement.ValueElement); this.GetBordersFromVisualCell((PropertyGridSpreadExportCell)exportContentCell3, (LightVisualElement)propertyGridItemElement); } this.OnCellFormatting(new PropertyGridSpreadExportCellFormattingEventArgs((PropertyGridSpreadExportCell)exportContentCell3, (PropertyGridItemBase)propertyGridItem, currentRowIndex)); gridSpreadExportRow.Cells.Add((PropertyGridSpreadExportCell)exportContentCell3); } if (this.ExportVisualSettings) { this.elementProvider.CacheElement((IVirtualizedElement <PropertyGridItemBase>)propertyGridItemElement); propertyGridItemElement.Detach(); this.propertyGrid.PropertyGridElement.PropertyTableElement.ViewElement.Children.Remove((RadElement)propertyGridItemElement); } } else if (item is PropertyGridGroupItem) { this.isGridGrouped = true; PropertyGridGroupItem propertyGridGroupItem = item as PropertyGridGroupItem; PropertyGridGroupElement gridGroupElement = (PropertyGridGroupElement)null; if (this.ExportVisualSettings) { gridGroupElement = this.elementProvider.GetElement((PropertyGridItemBase)propertyGridGroupItem, (object)null) as PropertyGridGroupElement; this.propertyGrid.PropertyGridElement.PropertyTableElement.ViewElement.Children.Add((RadElement)gridGroupElement); gridGroupElement.Attach((PropertyGridItemBase)propertyGridGroupItem, (object)null); } PropertyGridSpreadExportContentCell exportContentCell = new PropertyGridSpreadExportContentCell(); exportContentCell.Text = propertyGridGroupItem.Label; ++exportContentCell.ColSpan; ++exportContentCell.ColSpan; exportContentCell.ColSpan += this.depthOfTree; if (this.ExportDescriptions) { ++exportContentCell.ColSpan; } exportContentCell.Size = new Size(this.textCellWidth + this.valueCellWidth + this.depthOfTree * this.ItemIndent, -1); if (this.ExportVisualSettings) { this.GetStylesFromVisualCell((PropertyGridSpreadExportCell)exportContentCell, (LightVisualElement)gridGroupElement.TextElement); this.GetBordersFromVisualCell((PropertyGridSpreadExportCell)exportContentCell, (LightVisualElement)gridGroupElement.TextElement); } this.OnCellFormatting(new PropertyGridSpreadExportCellFormattingEventArgs((PropertyGridSpreadExportCell)exportContentCell, (PropertyGridItemBase)propertyGridGroupItem, currentRowIndex)); gridSpreadExportRow.Cells.Add((PropertyGridSpreadExportCell)exportContentCell); if (this.ExportVisualSettings) { this.elementProvider.CacheElement((IVirtualizedElement <PropertyGridItemBase>)gridGroupElement); gridGroupElement.Detach(); this.propertyGrid.PropertyGridElement.PropertyTableElement.ViewElement.Children.Remove((RadElement)gridGroupElement); } } if (!exportChildItemsHidden) { exportChildItemsHidden = !item.Expanded && this.CollapsedItemOption == HiddenOption.ExportAsHidden; collapsedParentLevel = itemLevel; } return(gridSpreadExportRow); }
void CreateGrid() { if (selobj == null) { return; } Controls.Clear(); properties.Clear(); proplist.Clear(); itemcounter = catcounter = subcounter = 0; Controls.Add(new PropertyGridHeader()); Hashtable cats = new Hashtable(); foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(selobj)) { if (!pd.IsBrowsable) { continue; } string cat = pd.Category; Hashtable mems = cats[cat] as Hashtable; if (mems == null) { cats[cat] = mems = new Hashtable(); } try { PropertyGridItem pgi = new PropertyGridItem(pd); pgi.controlid = ClientID + "_" + itemcounter++; properties[pgi.controlid] = pgi; object o = selobj; object subo = null; try { subo = pd.GetValue(o); } catch { } if (pd.Converter.GetPropertiesSupported()) { foreach (PropertyDescriptor spd in pd.Converter.GetProperties(subo)) { if (spd.IsBrowsable) { PropertyGridItem pgsi = new PropertyGridSubItem(spd, pgi); pgsi.controlid = ClientID + "_" + itemcounter++; pgi.subitems.Add(pgsi); properties[pgsi.controlid] = pgsi; } } } mems.Add(pd.Name, pgi); } catch (Exception ex) { Page.Response.Write(ex); } } this.catlist.Clear(); ArrayList catlist = new ArrayList(cats.Keys); catlist.Sort(); System.Web.UI.HtmlControls.HtmlContainerControl cc = new System.Web.UI.HtmlControls.HtmlGenericControl("div"); cc.ID = "cats"; Controls.Add(cc); foreach (string cat in catlist) { PropertyGridCategory pgc = new PropertyGridCategory(); pgc.CategoryName = cat; this.catlist.Add(pgc); cc.Controls.Add(pgc); Hashtable i = cats[cat] as Hashtable; ArrayList il = new ArrayList(i.Keys); il.Sort(); foreach (string pginame in il) { PropertyGridItem pgi = i[pginame] as PropertyGridItem; proplist.Add(pgi); pgc.Controls.Add(pgi); if (pgi.subitems.Count > 0) { SubItems si = new SubItems(); pgi.Controls.Add(si); foreach (PropertyGridItem spgi in pgi.subitems) { si.Controls.Add(spgi); proplist.Add(spgi); } } } } Controls.Add(new PropertyGridFooter()); }
public PropertyGridSubItem(PropertyDescriptor pd, PropertyGridItem parentitem) : base(pd) { this.parentitem = parentitem; }
void _pointEditor_propertyGridItemAssigned(PropertyGridItem gridItem) { gridItem.IsSelectedChanged += _gridItem_IsSelectedChanged; BackColor = gridItem.Owner.Owner.SectionBackColor; }
void radPropertyGrid1_Edited(object sender, PropertyGridItemEditedEventArgs e) { PropertyGridItem item = e.Item as PropertyGridItem; item.ErrorMessage = ""; }
void _handlePropertyGridItemAssigned(PropertyGridItem gridItem) { gridItem.IsSelectedChanged += new EventHandler(_gridItem_IsSelectedChanged); }
public DescriptorItemAccessor(PropertyGridItem owner, PropertyDescriptor descriptor) : base(owner) { this.descriptor = descriptor; }
private void CreateEditor() { if (_selectedObject == null) { return; } Controls.Clear(); _properties.Clear(); _proplist.Clear(); _itemcounter = 0; _catcounter = 0; _subcounter = 0; var cats = new Hashtable(); foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(_selectedObject)) { if (!pd.IsBrowsable) { continue; } var cat = pd.Category ?? "Default"; var mems = cats[cat] as Hashtable; if (mems == null) { cats[cat] = mems = new Hashtable(); } try { var pgi = new PropertyGridItem(pd) { ControlId = ID + "_" + _itemcounter++ }; _properties[pgi.ControlId] = pgi; var o = _selectedObject; object subo = null; try { subo = pd.GetValue(o); } catch { } if (pd.Converter.GetPropertiesSupported()) { foreach (PropertyDescriptor spd in pd.Converter.GetProperties(subo)) { if (!spd.IsBrowsable) { continue; } PropertyGridItem pgsi = new PropertyGridSubItem(spd, pgi); pgsi.ControlId = ID + "_" + _itemcounter++; pgi.Subitems.Add(pgsi); _properties[pgsi.ControlId] = pgsi; } } var orderAttribute = pd.Attributes.OfType <PropertyOrderAttribute>().FirstOrDefault(); var order = orderAttribute != null?orderAttribute.Order.ToString("D3") : "999"; mems.Add(order + pd.Name, pgi); } catch (Exception ex) { Page.Response.Write(ex); } } _catlist.Clear(); var catlist = new ArrayList(cats.Keys); catlist.Sort(); HtmlContainerControl cc = new HtmlGenericControl("div"); cc.ID = "cats"; Controls.Add(cc); foreach (string category in catlist) { if (HiddenCategories != null) { if (HiddenCategories.Contains(category)) { continue; } } var pgc = new PropertyGridCategory { CategoryName = category }; _catlist.Add(pgc); cc.Controls.Add(pgc); var i = cats[category] as Hashtable; var il = new ArrayList(i.Keys); il.Sort(); foreach (string pginame in il) { var pgi = i[pginame] as PropertyGridItem; _proplist.Add(pgi); pgc.Controls.Add(pgi); if (pgi.Subitems.Count > 0) { var si = new SubItems(); pgi.Controls.Add(si); foreach (PropertyGridItem spgi in pgi.Subitems) { si.Controls.Add(spgi); _proplist.Add(spgi); } } } } }