Where is DataGrid.HitTestInfo

Skip to first unread message

gert birkner

Sep 16, 2001, 10:47:27 AM9/16/01
for me it愀 not possible to get the HitTest like:
(e.X, e.Y: it愀 in a MouseUp event)
DataGrid.HitTestInfo hti = myGrid.HitTest(e.X, e.Y);

There is no HitTestInfo in DataGrid and in addition no HitTestType.
What do I miss?

Jacob Yang

Sep 17, 2001, 5:56:03 AM9/17/01
Hi Gert,

I have found the examples in MSDN for your reference.


[Visual Basic]
NotInheritable Public Class DataGrid.HitTestInfo
public sealed class DataGrid.HitTestInfo
public __gc __sealed class DataGrid.HitTestInfo
public class DataGrid.HitTestInfo
The DataGrid.HitTestInfo class, in conjunction with the HitTest method of
the DataGrid control, is used to determine which part of a DataGrid control
the user has clicked. The DataGrid.HitTestInfo contains both the row,
column and part of the grid that was clicked. See the DataGrid.HitTestType
enumeration returned by the Type property for a complete list of grid parts.

To return a DataGrid.HitTestInfo object, invoke the HitTest method inside
the MouseDown event of DataGrid control. Pass the x and y parameters to the
HitTest method.

[Visual Basic, C#] The following example uses the HitTest method in a
MouseDown event to return the DataGrid.HitTestInfo object. The row, column,
and part of the grid are then printed.

[Visual Basic]
Public Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As
Dim myHitTest As DataGrid.HitTestInfo
' Use the DataGrid control's HitTest method with the x and y properties.
myHitTest = DataGrid1.HitTest(e.X, e.Y)
Console.WriteLine("Column " & myHitTest.Column)
Console.WriteLine("Row " & myHitTest.Row)
Console.WriteLine("Type " & myHitTest.Type)
Console.WriteLine("ToString " & myHitTest.ToString)
Console.WriteLine("Format " & myHitTest.Type.ToString)
End Sub
protected void dataGrid1_MouseDown
(object sender, System.Windows.Forms.MouseEventArgs e)
System.Windows.Forms.DataGrid.HitTestInfo myHitTest;
// Use the DataGrid control's HitTest method with the x and y properties.
myHitTest = dataGrid1.HitTest(e.X,e.Y);
Console.WriteLine("Column " + myHitTest.Column);
Console.WriteLine("Row " + myHitTest.Row);
Console.WriteLine("Type " + myHitTest.Type);
Console.WriteLine("ToString " + myHitTest.ToString());
Console.WriteLine("Hit " + myHitTest.Type.ToString());
[C++, JScript] No example is available in C++ or JScript. To view a Visual
Basic or C# example, click the Language Filter button in the upper-left
corner of the page.

I hope this helps.

Jacob Yang

Reply all
Reply to author
0 new messages