Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Where is DataGrid.HitTestInfo

6 views
Skip to first unread message

gert birkner

unread,
Sep 16, 2001, 10:47:27 AM9/16/01
to
Beta2
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

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

I have found the examples in MSDN for your reference.

DataGrid.HitTestInfo

[Visual Basic]
NotInheritable Public Class DataGrid.HitTestInfo
[C#]
public sealed class DataGrid.HitTestInfo
[C++]
public __gc __sealed class DataGrid.HitTestInfo
[JScript]
public class DataGrid.HitTestInfo
Remarks
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.

Example
[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
MouseEventArgs)
Console.WriteLine()
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
[C#]
protected void dataGrid1_MouseDown
(object sender, System.Windows.Forms.MouseEventArgs e)
{
Console.WriteLine();
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(myHitTest);
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

0 new messages