How to lock the column width expansion in list view at run time
-
Hi Just a simple approach, but not feasible, see bellow code
private void listView1_ColumnWidthChanged(object sender, ColumnWidthChangedEventArgs e)
{
if(listView1.Columns[e.ColumnIndex].Width != 50)
listView1.Columns[e.ColumnIndex].Width = 50;
}check the static column width, if it miss matches then it is changed so reset it , this is a simple approach, if you find some other good method follow that. thanks
-
Hi Just a simple approach, but not feasible, see bellow code
private void listView1_ColumnWidthChanged(object sender, ColumnWidthChangedEventArgs e)
{
if(listView1.Columns[e.ColumnIndex].Width != 50)
listView1.Columns[e.ColumnIndex].Width = 50;
}check the static column width, if it miss matches then it is changed so reset it , this is a simple approach, if you find some other good method follow that. thanks
Actually this would a little be better:
private void listView1_ColumnWidthChanged(object sender, ColumnWidthChangedEventArgs e)
{
e.Cancel = true;
e.NewWidth = listView1.Columns[e.ColumnIndex].Width;
}