DataGridTableStyle and BindingSource problems

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.
 
J

Jason James

Arun,

no luck I'm afraid. The datagrid returned "BindingSource" when I
executed

dgTableStyle.MappingName =
itemsDataGrid.DataSource.GetType().Name;

The issue appears to be the binding source to link tables using their
foreignkey relationships.

Any other ideas?

Jason.
 
T

tolega

Arun,

no luck I'm afraid.  The datagrid returned "BindingSource" when I
executed

        dgTableStyle.MappingName =
itemsDataGrid.DataSource.GetType().Name;

The issue appears to be the binding source to link tables using their
foreignkey relationships.

Any other ideas?

Jason.

I am experiencing the same problem.

Master table bound to the first grid, uses tablestyle without problem,
but the detail wich is bound to a BindingSource (related table)
doesn't apply.

Tried in MappingName:
-TableName
-Relation name.

Isn't it a bug?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top