Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

winforms listview - make first column always visible?

I have an application (winforms, c#) that displays data in a Listview in a very usual way - the first row is headers, the first column in each row is header and the following sub-items is the data itself.

I want the first column (the headers columns) always visible and the horizontal scroll to affect the other columns only.

i don't think it is possible in winforms listview (am i wrong?). Hence, i'm thinking to split the listview to two listviews - one for headers and the second for data. In that case, i need to connect the vertical scroll bars - a task which i find to be harder than i've expected.

Am i taking a wrong path (e.g. would it be easier to use a different control)? If not, any pointers on how to implement it?

Note: Winforms Listview has poor API (e.g. no scrolling event) and is known as buggy, so i'm looking a working sample rather than MSDN links...

Thanks

like image 788
Hertzel Guinness Avatar asked Apr 21 '11 08:04

Hertzel Guinness


2 Answers

As already noted the DataGridView supports this behaviour, but nobody told how this will be done:

To enable this feature simply set the Frozen property of a column. Further informations can also be found in this How to: Freeze Columns in the Windows Forms DataGridView Control.

like image 117
Oliver Avatar answered Sep 21 '22 23:09

Oliver


I think you have to try to use the DatagridView instead of the listbox. As far as I know, the DataGridView supports this.

like image 32
Rhapsody Avatar answered Sep 17 '22 23:09

Rhapsody