J
Jørgen Fredborg
Hi all
Im loosing my mind here. I am trying to create a datagrid with 2 columns.
The first column must have a width of 50 while the second column must have
width 150.
I cant figure out the relationship between datagrid, datatable, and
tablesstyles.
I have tried this code:
DataTable data = new DataTable();
data.Columns.Add("Date");
data.Columns.Add("Order");
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = "Order"; <-- What should this be mapped to ?
// Order date column style
DataGridColumnStyle orderDate = new DataGridTextBoxColumn();
shipName.MappingName = "Date";
orderDate.HeaderText = "Date";
orderDate.Width = 50;
ts.GridColumnStyles.Add(orderDate);
// Shipping name column style
DataGridColumnStyle shipName = new DataGridTextBoxColumn();
shipName.MappingName = "Order";
shipName.HeaderText = "Shipping";
shipName.Width = this.Width - orderDate.Width - 37;
ts.GridColumnStyles.Add(shipName);
data.Rows.Add("12-04-2004","Ship no. 1");
DataGrid1.TableStyles.Add(ts);
DataGrid1.DataSource = data;
It doesnt work, Plz help
Im loosing my mind here. I am trying to create a datagrid with 2 columns.
The first column must have a width of 50 while the second column must have
width 150.
I cant figure out the relationship between datagrid, datatable, and
tablesstyles.
I have tried this code:
DataTable data = new DataTable();
data.Columns.Add("Date");
data.Columns.Add("Order");
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = "Order"; <-- What should this be mapped to ?
// Order date column style
DataGridColumnStyle orderDate = new DataGridTextBoxColumn();
shipName.MappingName = "Date";
orderDate.HeaderText = "Date";
orderDate.Width = 50;
ts.GridColumnStyles.Add(orderDate);
// Shipping name column style
DataGridColumnStyle shipName = new DataGridTextBoxColumn();
shipName.MappingName = "Order";
shipName.HeaderText = "Shipping";
shipName.Width = this.Width - orderDate.Width - 37;
ts.GridColumnStyles.Add(shipName);
data.Rows.Add("12-04-2004","Ship no. 1");
DataGrid1.TableStyles.Add(ts);
DataGrid1.DataSource = data;
It doesnt work, Plz help