J
Jason James
Hi,
I can create a custom table style when binding a datagrid directly to
a datatable (typed on non-typed). The code below works just fine:
DataGridTableStyle dgTableStyle = new
DataGridTableStyle();
dgTableStyle.MappingName = stockDataSet.Items.TableName;
DataGridTextBoxColumn dgPartNumber = new
DataGridTextBoxColumn();
dgPartNumber.HeaderText = "Part Number";
dgPartNumber.MappingName = "iPartNumber";
dgTableStyle.GridColumnStyles.Add(dgPartNumber);
itemsDataGrid.TableStyles.Add(dgTableStyle);
when the data grid is bound to the following:
itemsDataGrid.DataSource = stockDataSet.Items;
However, the items table is related to a parent table as a child. I
therefore have created a binding source (in fact there is a parent to
the parent, and a parent of that), i.e. the Items table is a great
grand child table, all linked with binding sources.
bsDepartment = new BindingSource();
bsDepartment.DataSource = this.stockDataSet.Department;
bsArea = new BindingSource();
bsArea.DataSource = bsDepartment;
bsArea.DataMember = "FK_Area_Department";
bsLocation = new BindingSource();
bsLocation.DataSource = bsArea;
bsLocation.DataMember = "FK_Location_Area";
bsItems = new BindingSource();
bsItems.DataSource = bsLocation;
bsItems.DataMember = "FK_Items_Location";
My problem is trying to create a table style for the items table when
configured using a binding source. When using the binding source the
table style is never applied.
Does anyone have any thoughts as to why this might be and what the fix
is? I really don't want to have to trap the event raised when the
binding source position is changed and apply a row filter.
Many thanks,
Jason.
I can create a custom table style when binding a datagrid directly to
a datatable (typed on non-typed). The code below works just fine:
DataGridTableStyle dgTableStyle = new
DataGridTableStyle();
dgTableStyle.MappingName = stockDataSet.Items.TableName;
DataGridTextBoxColumn dgPartNumber = new
DataGridTextBoxColumn();
dgPartNumber.HeaderText = "Part Number";
dgPartNumber.MappingName = "iPartNumber";
dgTableStyle.GridColumnStyles.Add(dgPartNumber);
itemsDataGrid.TableStyles.Add(dgTableStyle);
when the data grid is bound to the following:
itemsDataGrid.DataSource = stockDataSet.Items;
However, the items table is related to a parent table as a child. I
therefore have created a binding source (in fact there is a parent to
the parent, and a parent of that), i.e. the Items table is a great
grand child table, all linked with binding sources.
bsDepartment = new BindingSource();
bsDepartment.DataSource = this.stockDataSet.Department;
bsArea = new BindingSource();
bsArea.DataSource = bsDepartment;
bsArea.DataMember = "FK_Area_Department";
bsLocation = new BindingSource();
bsLocation.DataSource = bsArea;
bsLocation.DataMember = "FK_Location_Area";
bsItems = new BindingSource();
bsItems.DataSource = bsLocation;
bsItems.DataMember = "FK_Items_Location";
My problem is trying to create a table style for the items table when
configured using a binding source. When using the binding source the
table style is never applied.
Does anyone have any thoughts as to why this might be and what the fix
is? I really don't want to have to trap the event raised when the
binding source position is changed and apply a row filter.
Many thanks,
Jason.