Data columns are columns that are designed to be bound to a specific data source field. Data columns are represented by the NDataColumn class. Usually data columns are created automatically when you bind the grid to data (see Data Binding and Column Generation). You can however manually create data columns like this:
Data Columns |
Copy Code
|
---|---|
// create a dummy data table NMemoryDataTable dataTable = new NMemoryDataTable(new NFieldInfo[]{ new NFieldInfo("Name", typeof(String)), new NFieldInfo("Job Title", typeof(String)), }); dataTable.AddRow("Jinny Collazo", "President"); dataTable.AddRow("John Duke", "VicePresident"); dataTable.AddRow("Kellie Ferrell", "SalesManager"); // bind the grid to the data source, but do not auto create columns grid.AutoCreateColumns = false; grid.DataSource = new NDataSource(dataTable); // create a data column and bind it to the data source NDataColumn dataColumn = new NDataColumn(); dataColumn.Bind(grid.DataSource, "Job Title", "Job Title"); grid.Columns.Add(dataColumn); |
As you can see the binding of a data column to a data source field is achieved via the data column Bind method.