Example E2098
Visible to All Users

WinForms Property Grid - Create editor and category rows

This example demonstrates how to create editor and category rows and add them to the PropertyGrid control:

C#
void CreateRows() { EditorRow rowLastName = new EditorRow("LastName"); rowLastName.Properties.Caption = "Last name"; propertyGridControl1.Rows.Add(rowLastName); CategoryRow rowCategory = new CategoryRow("Address"); propertyGridControl1.Rows.Add(rowCategory); EditorRow rowAddressLine1 = new EditorRow("AddressLine1"); rowAddressLine1.Properties.Caption = "Address Line 1"; rowCategory.ChildRows.Add(rowAddressLine1); EditorRow rowZip = new EditorRow("Zip"); rowZip.Properties.Caption = "Zip Code"; rowCategory.ChildRows.Add(rowZip); }

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

AddRowsRuntime/Form1.cs(vb)
C#
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using DevExpress.XtraVerticalGrid.Rows; namespace AddRowsRuntime { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { propertyGridControl1.AutoGenerateRows = false; CreateRows(); Person person = new Person(); person.LastName = "Doe"; person.FirstName = "John"; propertyGridControl1.SelectedObject = person; } private void CreateRows() { EditorRow rowLastName = new EditorRow("LastName"); rowLastName.Properties.Caption = "Last name"; propertyGridControl1.Rows.Add(rowLastName); CategoryRow rowCategory = new CategoryRow("Address"); propertyGridControl1.Rows.Add(rowCategory); EditorRow rowAddressLine1 = new EditorRow("AddressLine1"); rowAddressLine1.Properties.Caption = "Address Line 1"; rowCategory.ChildRows.Add(rowAddressLine1); EditorRow rowZip = new EditorRow("Zip"); rowZip.Properties.Caption = "Zip Code"; rowCategory.ChildRows.Add(rowZip); } } public class Person { private string _FirstName; public string FirstName { get { return _FirstName; } set { _FirstName = value; } } private string _LastName; public string LastName { get { return _LastName; } set { _LastName = value; } } private string _AddressLine1; public string AddressLine1 { get { return _AddressLine1; } set { _AddressLine1 = value; } } private string _Zip; public string Zip { get { return _Zip; } set { _Zip = value; } } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.