D
Dale Williams
Everyone:
Using C#, I'm trying to create a datagrid on a winform programatically.
I placed the datagrid and the form and named it CHGrid. Here's the
code I'm using:
// Get and bind the data.
QarBusTier.DefectFoundLocation DFL = new
QarBusTier.DefectFoundLocation();
System.Data.DataTable DFLTable = DFL.LoadAll();
CHGrid.DataSource = DFLTable;
// Set the data grid style.
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "Customers";
// Set the datagrid style.
CHGrid.Top = 50;
CHGrid.Left = 200;
CHGrid.Width = 350;
CHGrid.Height= 200;
CHGrid.ForeColor = System.Drawing.Color.Black;
CHGrid.BackColor = System.Drawing.Color.Beige;
// Create column.
DataGridBoolColumn myDataCol = new DataGridBoolColumn();
myDataCol.MappingName = "DefectFoundLocationId";
myDataCol.HeaderText = "My New Column";
myDataCol.Width = 100;
ts1.GridColumnStyles.Add(myDataCol);
CHGrid.TableStyles.Add(ts1);
The DFL.LoadAll() just gets all the data from a table. My grid is
populated with the 4 columns being returned from DFL.LoadAll() but the
column I create is not being displayed.
I want to display only the column(s) I create and not have the grid
auto-populate.
Thanks for the help,
Dale Williams
Using C#, I'm trying to create a datagrid on a winform programatically.
I placed the datagrid and the form and named it CHGrid. Here's the
code I'm using:
// Get and bind the data.
QarBusTier.DefectFoundLocation DFL = new
QarBusTier.DefectFoundLocation();
System.Data.DataTable DFLTable = DFL.LoadAll();
CHGrid.DataSource = DFLTable;
// Set the data grid style.
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "Customers";
// Set the datagrid style.
CHGrid.Top = 50;
CHGrid.Left = 200;
CHGrid.Width = 350;
CHGrid.Height= 200;
CHGrid.ForeColor = System.Drawing.Color.Black;
CHGrid.BackColor = System.Drawing.Color.Beige;
// Create column.
DataGridBoolColumn myDataCol = new DataGridBoolColumn();
myDataCol.MappingName = "DefectFoundLocationId";
myDataCol.HeaderText = "My New Column";
myDataCol.Width = 100;
ts1.GridColumnStyles.Add(myDataCol);
CHGrid.TableStyles.Add(ts1);
The DFL.LoadAll() just gets all the data from a table. My grid is
populated with the 4 columns being returned from DFL.LoadAll() but the
column I create is not being displayed.
I want to display only the column(s) I create and not have the grid
auto-populate.
Thanks for the help,
Dale Williams