Earlier My approach was to set the column width for the listview with width=0 as shown below.
[ListViewName].Columns.Add("ID", 0);
It worked fine when I run the application, but the problem I found was that still user was able to change the width. To resolve that Issue I tried following thing and It worked like a charm.
Just open the form and Select ListView. Go to events grid and find "ColumnWidthChanged" event.
Create event and put the code as shown below.
private void [ListViewName]_ColumnWidthChanged(object sender, ColumnWidthChangedEventArgs e) { if (e.ColumnIndex == 0) { this.[ListViewName].Columns[e.ColumnIndex].Width = 0; } }
Cheers,
Ashish Chotalia
P.S. Please replace "[ListViewName]" with your ListView Id.
No comments:
Post a Comment