I have the application look like it stops the width at 50, but if the mouse is dragged further on and then let up, the width will be below:
private void ListView1_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
{
if (e.ColumnIndex ==0 & e.NewWidth <50)
{
e.Cancel = true;
}
}
I cannot work out how to force the ColumnWidthChanged
width to 50 if the changed width = < 50
. I don't need to fix the column widths, as information will vary in length, but force a minimum width.
Any suggestions?
If you want to change the Width after the user has finished dragging the column separator you can do this
private const int _minimumColumnWidth = 50;
private void ListView1_ColumnWidthChanged(object sender, ColumnWidthChangedEventArgs e)
{
if (ListView1.Columns[e.ColumnIndex].Width < _minimumColumnWidth)
{
ListView1.Columns[e.ColumnIndex].Width = _minimumColumnWidth;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With