Home All Groups Group Topic Archive Search About

Retaining column widths in the datagridview (.net 2.0) :-(

Author
8 Mar 2007 4:57 PM
Simon Harvey
Hi all,

Can anyone tell me if there is an easy way to retain per-user column
widths for the datagridview in a windows forms application.

I know I could do it with a lot of database programming and what not,
but I was hoping there would be a much easier solution. It seems like
such an obvious requirement, but I can find any articles on how to do it.

Many thanks to anyone who can advise

Kindest Regards

Simon

Author
8 Mar 2007 7:09 PM
Andrew Stoneham
Have you considered making a dataset and storing the values in there (along
the lines of 1 table with 3 columns [tablename, columnname, width] and just
adding the values through a loop) then saving the xml in the users
application data folder.

Then when the application starts, load the xml file if it exists and restore
the changes.

Show quote
"Simon Harvey" wrote:

> Hi all,
>
> Can anyone tell me if there is an easy way to retain per-user column
> widths for the datagridview in a windows forms application.
>
> I know I could do it with a lot of database programming and what not,
> but I was hoping there would be a much easier solution. It seems like
> such an obvious requirement, but I can find any articles on how to do it.
>
> Many thanks to anyone who can advise
>
> Kindest Regards
>
> Simon
>
Author
8 Mar 2007 7:33 PM
Simon
Hi Andrew

Thanks very much for your thoughts. If there isn't an easier way I may
have to do just that - but I'm holding out for something simpler! :-)

I'm just hoping, perhaps in vain, that there is some dead easy way to
get this to work using some Visual Studio design time trickery.

Anyone?

Thanks again

Simon
Author
9 Mar 2007 11:31 AM
Kevin Spencer
You can bind them to User-scoped Application Settings. I'm not sure whether
this can be done explicitly in the Designer, but it isn't hard. Here are a
couple of references for you:

http://msdn2.microsoft.com/en-us/library/0zszyc6e.aspx
http://msdn2.microsoft.com/en-us/library/0yyxh69h(vs.80).aspx

--
HTH,

Kevin Spencer
Microsoft MVP

Help test our new betas,
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

Show quote
"Simon" <si***@nothanks.com> wrote in message
news:OlI$hibYHHA.4560@TK2MSFTNGP03.phx.gbl...
> Hi Andrew
>
> Thanks very much for your thoughts. If there isn't an easier way I may
> have to do just that - but I'm holding out for something simpler! :-)
>
> I'm just hoping, perhaps in vain, that there is some dead easy way to get
> this to work using some Visual Studio design time trickery.
>
> Anyone?
>
> Thanks again
>
> Simon

AddThis Social Bookmark Button