Multiple tablestyles and one table?

B

Brett Romero

I have one DataTable used in a datagrid. I have multiple TableStyles
to defining various views of the data. The table contains 20 unique
columns. I have four TableStyles, each with containing five columns.
I'd like to switch out these four views on button clicks. One view
will display at a time. Rather than create four datatables, I feel the
tablestyles and switching them is quicker. Comments?

For some reason, it isn't working. I do this in form_load() where dgts
is a gridtablestyle object:
dgtsSummary.MappingName = "Summary";
dggrid.TableStyles.Add(dgtsSummary);

I'm doing this on a button click for testing:
ds.Tables[0].TableName = dgtsSummary.MappingName;
dggrid.Refresh();

Right now, the tablestyle has only one mapped column, which should make
the grid display only that column. However, I'm still seeing all
columns. Each column in the table does have a space. Is the correct
mapping name "[some column]" or just "some column"?

Finally, how do I switch grid views by changing the mappings upon
button clicks?

Thanks,
Brett
 
B

Brett Romero

Ok, here it is:

case 0:
{
dggrid.TableStyles.Clear();
dggrid.TableStyles.Add(gridstyle1);
break;
}
case 1:
{
dggrid.TableStyles.Clear();
dggrid.TableStyles.Add(gridstyle2);
break;
}

Each gridstyle object should have the name of the table your mapping
to.

Brett
 

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