Changing DataGrid Column headings

  • Thread starter Mac via DotNetMonster.com
  • Start date
M

Mac via DotNetMonster.com

I am attempting to change the header text on all the columns in my datagrid
once it was been populated from a dataset. I have tried to implement some
code from the following MSDN document but what I get is all my columns
having the same values and header text as the last column I added to
DataGridTableStyle I was creating.

Can anyone assist?

Here is the link:
http://msdn.microsoft.com/vbasic/using/building/windows/datagrid/default.aspx?
pull=/library/en-us/dnwinforms/html/wnf_CustDataGrid.asp


regards,

Mac
 
G

Guest

Hi,

If the mappingname for the tablestyle is wrong the tablestyle will have
no effect. Try using the dataset.table(0).tablename for the tablestyles
mapping name

Ken
 
M

Mac via DotNetMonster.com

Thanks for replying Ken.


I currently have tablestyle.mappingname = "Policies" and the name of the
datatable bound to the datagrid is the same name.

Is this correct?
 
M

Mac via DotNetMonster.com

Don't bother - I got it working. Looks like the code was incorrect.

Each column I was adding to the tablestyle used the same variable, which is
obviously why when it came time to update the datagrid with the style it
used the last update value, which was the last column.

To resolve I created a separate variable for each column and that did the
trick!
 
C

Cor Ligthert

Mac,

It is a standard problem. You did probably not create every column as a
"New" column and now you did that automatic with giving them all another
name.

To give you an answer on the "why".

I hope this helps,

Cor
 

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