Make a .NET Winforms DataGrid have no current cell

You can do this by subclassing your DataGrid and adding the following code:

    Public Class DataGridEx  	
        Inherits DataGrid  	
	
        Public WM_LBUTTONDOWN As Integer = 513  	
        Public WM_LBUTTONUP As Integer = 514  	
	
        Shared Function SendMessage(hWnd As IntPtr, msg As Int32, _
            wParam As Int32, lParam As Int32) As Boolean  	

        Public Sub NoCurrentCell()  	
            '
            ' Simulate a click on top left corner of the grid.
            '
            SendMessage(Me.Handle, WM_LBUTTONDOWN, 0, 0)  	
            SendMessage(Me.Handle, WM_LBUTTONUP, 0, 0)  	
        End Sub
    End Class	



About TheScarms
About TheScarms


Sample code
version info

If you use this code, please mention "www.TheScarms.com"

Email this page


© Copyright 2024 TheScarms
Goto top of page