I want to disable the column width auto-adjustable feature of a datagrid. That is the default behavior when users double-click the column divider line on the row header and the width of that column will adjust to fit the max length of its content.
Using HitTest, my following code tried to detect the double click on the divider line, and somehow to disbale the resize, but it is not working. I could not even get to Exit Sub part.
By the way, this is a vs2003 datagrid, not vs2005 datagridView. Thanks!
Private Sub dgbyCSR_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgbyCSR.DoubleClick
Dim pt As System.Drawing.Point = dgbyCSR.PointToClient(Windows.Forms.Cursor.Position)
Dim hti As DataGrid.HitTestInfo = dgbyCSR.HitTest(pt)
If hti.Type = DataGrid.HitTestType.ColumnResize Then
'do nothing to prevent users from auto-adjust column width
Else 'do other normal stuff
I guess I could ask my question in another way. Most of hittest samples I got are firing off from datagrid_MouseUp/Down event, which has this args,
ByVal e As System.Windows.Forms.MouseEventArgs
however, on the datagrid_doubleClick, the default args is System.EventArgs.
I am not sure how would you detect a double click on the column divider. If I could have that figure out, only then, my original question is valid.