Monday, July 2, 2012

Prevent Listview column from being resized (Winform)

I added the snippet below in the columnwidthchanging event:
Code:
  switch (e.ColumnIndex)  
        {  
          case 0:  
            e.NewWidth = 400;  
            break;  
          case 1:  
            e.NewWidth = 200;  
            break;  
          case 2:  
            e.NewWidth = 100;  
            break;  
          case 3:  
            e.NewWidth = 100;  
            break;  
          default:  
            break;  
        }  
       e.Cancel = true;

Where 400, 200, and 100 are the original column sizes.

0 comments:

Post a Comment