Hi there,
Long-time lurker, first-time poster:
I'm working with the ExtendedDatagri d
(http://dotnet.leadit.be/extendeddatagrid/) control to display a grid
representing an array of objects I've created.
In the form below the datagrid is displayed with the correct columns,
and the correct data (as added at the bottom of the code with my
partial-datarow). However, this is displayed using the default style,
and not the custom-controls i specified in my styles.
If i uncomment the line that adds my tablestyle to the datagrid,
things appear to break. All that is shown is an empty datagrid.
This has been making me tear my hair out for the last two days. If you
can put me out my misery, or can point out a better way to approach my
problem i'm all ears!
Thanks!
Andrew
code:
-----
DataTable dt = new DataTable("Cust omersMatrix");
dt.Columns.Add( "Customers" );
ft.Columns.Add( "SalesMargins") ;
foreach (string p in Products)
{
dt.Columns.Add( p);
}
// Create datagrid table style
ExtendedDataGri dTableStyle ts = new ExtendedDataGri dTableStyle();
ts.MappingName = "Customers[]";
// create datagrid column styles for first two columns
ExtendedDataGri dControlColumn colCustomerName = new
ExtendedDataGri dControlColumn( );
colCustomerName .MappingName = "Name";
colCustomerName .HeaderText = "Customers" ;
colCustomerName .Control = typeof(Customer LabelColumnCont rol);
DataGridTextBox Column colSalesMarginL abel = new
DataGridTextBox Column();
colSalesMarginL abel.MappingNam e = colSalesMarginL abel.HeaderText =
"SalesMargi n";
//colCustomerName .Control = typeof(Customer LabelColumnCont rol);
// for each product in the db, create a column style
ArrayList productColumnSt yles = new ArrayList();
ExtendedDataGri dControlColumn[] productColumnSt ylesArray;
foreach (string product in Products)
{
ExtendedDataGri dControlColumn colProduct = new
ExtendedDataGri dControlColumn( );
//colProduct.Mapp ingName = "Products";
colProduct.Head erText = product;
colProduct.Cont rol = typeof(ProductS alesMarginColum nControl);
productColumnSt yles.Add(colPro duct);
}
productColumnSt ylesArray =
(ExtendedDataGr idControlColumn[])productColumnS tyles.ToArray(t ypeof(ExtendedD ataGridControlC olumn));
// add all column styles to our tablestyle
ts.GridColumnSt yles.Add(colCus tomerName);
ts.GridColumnSt yles.Add(colSal esMarginLabel);
ts.GridColumnSt yles.AddRange(p roductColumnSty lesArray);
// add our tablestyle to the datagrid
//extendedDataGri d.TableStyles.A dd(ts);
DataRow dr = dt.NewRow();
dr["Customers"] = "Carrefour" ;
dr["SalesMargi ns"] = "Sales\nMargins ";
dr["Television s"] = new CustomerProduct Matrix.SalesMar gin(100,0.5m);
dt.Rows.Add(dr) ;
extendedDataGri d.DataSource = dt;