Saving setting for a datagridview control

Hi

I having a datagridview control and the user is alowed to resize the column width. The idea was to save the new width as a "user configuraton".

Using the "ColumnWidthChanged" event I detects when the user resizes the column and saves the new value.

At startup I reloads the new values......

Now to my problem,, it does not  work. The reason why,,,, seems to be...

The visual designer (using visaul 2005 express) seem to hardcode a comumn value into the "generated" section ( InitializeComponent() ).

What happends is that duning Initialization, the hardcoded values is set to the columns, a event is triggered, and my code saves the "faulty" values into the configuration file. This repeates every application startup, so any changes by the user, is always over written.

So.. is there a good way around this... (DesignMode does not work)

 

//lasse

 

 

 



Answer this question

Saving setting for a datagridview control

  • Jan V133422

    Try testing the Created property of the Form before saving the new values. During InitializeComponent, Created should be false, because it has not finished initializing yet.

  • Saving setting for a datagridview control