Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get grid's column widths
Message
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
00962477
Message ID:
00962640
Views:
7
Kevin,
Your assumption was correct, it is for a WinForm datagrid.
I dug the CoDe magazine out with your article. This must have been where I got the idea about saving the column widths from (and here I thought I came up with that great idea <s>).

An exception is thrown when I run the following code:
MessageBox.Show(this.dataGrid2.TableStyles[0].GridColumnStyles[10].Width.ToString());
The exception that was thrown was:
System.ArgumentOutOfRangeException: Index was out of range.  Must be non-negative and less than the size of the collection.
I did some investigation and it turns out that:
this.dataGrid2.TableStyles.Count is equal to 0
so that must be the problem. VisibleColumnCount is equal to 16 in my case.

Any idea why TableStyles.Count is equal to 0 (zero)?

Einar



>Hey, Einar,
>
>Just to follow up on what Vlad responded with - you should be able to accomplish this with the Winforms datagrid. (This was posted in the Winforms area, so I assume you're talking about the Winforms grid...if not, then you can ignore this message).
>
>But if it is for the winforms grid, tip #13 from my dataGrid article in CoDe shows how to save grid columns widths to an XML settings file. You can grab the column widths from a grid's tablestyle...
>
>
>
>myGrid.TableStyles[0].GridColumnStyles[nColumnNumber].Width;
>
>
>Hope this helps...
>Kevin
Semper ubi sub ubi.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform