Ralph Varjabedian
Sharing .NET Code and ideas

Remembering Column Sizes and Forms' Dimensions and Locations easily

Wednesday, July 02, 2008 4:52 PM

A common task that I encounter when I create Desktop Applications in .NET is that I need to make all my ListCtrls and DataGridViews remember their column sizes when the end user manually changes them. Also another common task is having forms remember their Width, Height, Position and WindowState every time your form opens. I have written some code to do just this. The code is written as Extensions to the ListCtrl, DataGridView and Form classes.

To use the code, you must add the file Extensions.cs to your project. To add the functionality to a ListCtrl just call ActivateRememberListViewColumns on the ListCtrl instance. To add the functionality to a DataGridView just call ActivateRememberDataGridViewColumns on the DataGridView instance. As for adding it to your Forms, just call ActivateRememberFormSizeAndPosition on the Form instance.

The code creates a folder called Settings under your working directory and saves the state files there.

Download the sample code here

Hope this helps.


Feedback

No comments posted yet.


Post a comment





 

Please add 7 and 8 and type the answer here: