ListView - Fixed Column Width

  • Thread starter Thread starter Craig Petrie
  • Start date Start date
C

Craig Petrie

Hi,
My client does not want users to change the width of a column in a ListView
control.

I have looked hard at properties/methods and events but can see no obvious
solution.

Does any one have a tip on how to handle this in vb.Net(2003)

Thanks
Craig
 
Craig,

I did something similar for a datagrid I was using. I derived a class from
the existing datagrid as follows:

Public Class MyDataGrid
Inherits DataGrid

' Overiding these two functions will make the grid so the user cannot
resize the columns of the grid
Protected Overrides Sub OnMouseMove(ByVal e As
System.Windows.Forms.MouseEventArgs)
Dim hti As DataGrid.HitTestInfo = Me.HitTest(New Point(e.X, e.Y))
If hti.Type = DataGrid.HitTestType.ColumnResize Then
Return 'no baseclass call
End If
MyBase.OnMouseMove(e)
End Sub

Protected Overrides Sub OnMouseDown(ByVal e As
System.Windows.Forms.MouseEventArgs)
Dim hti As DataGrid.HitTestInfo = Me.HitTest(New Point(e.X, e.Y))
If hti.Type = DataGrid.HitTestType.ColumnResize Then
Return 'no baseclass call
End If
MyBase.OnMouseDown(e)
End Sub

End Class

I would assume you would be able to do the same thing for the listview.....

Let me know if this works for you.

Thanks!

Jim
 
Back
Top