can not set the tablestyles to a data grid

  • Thread starter Thread starter Cyrus
  • Start date Start date
C

Cyrus

i defined a dataset and set it instance as the data source of the data grid
but i cannot find the mapping name of the table of this dataset inside the
tablestyle property, i dont know how to set the style
 
The simplest way, of course, is set DataGrid's TableStyle in Properties
window: click "TableStyles" property to add as many TableStyles as you want.
That means a sigle DataGrid can be bound to different datasource (Tables)
without extra configuration other than TableStyle. In each TableStyle, then,
you define GridColumnStyle for each column of the DataGrid, mapped to a
column in DataTable. You can also configure TableStyles/GridColumnStyles in
code programmingly.

Say, if your DataSet has to tables: "Table1" and "Table2". You can add two
TableStyles, mapping to "Table1" and "Table2" respectively. So, if in your
code, you do

DataGrid1.DataSource=MyDataSet
DataGrid1.DataMember="Table1"

The DataGrid will show the look as the TableStyle, mapped to "Table1",
defined. And later you may want to display data in "Table2", you simply do:

DataGrid1.DataSource=MyDataSet
DataGrid1.DataMember="Table2"

The DataGrid's look will change according to the definition of the other
TableStyle.
 
I know the way to do it in design time
but my problem is I can't find the dataset's table name in the TableStyles
property's mapping name
 
I know the way to do it in design time but my problem is I can't find
the dataset's table name in the TableStyles property's mapping name

If you don't know the table name, then how did you set the Data Member
of the grid? MappingName (assuming we're using datatables) is the same
name you gave when you set DataMember.

I'm tempted here to suggest "MyDataSet.Tables[0].TableName", which
might work for you, but I'm not sure I completely understand
the problem.
 
of coz i know the table name
what i said is that i cant find out the table name in the designer's
MappingName's drop down box
but i type it by myself and it's ok now


David said:
I know the way to do it in design time but my problem is I can't find
the dataset's table name in the TableStyles property's mapping name

If you don't know the table name, then how did you set the Data Member
of the grid? MappingName (assuming we're using datatables) is the same
name you gave when you set DataMember.

I'm tempted here to suggest "MyDataSet.Tables[0].TableName", which
might work for you, but I'm not sure I completely understand
the problem.
 
Back
Top