windowsforms-devexpress-dot-xtratreelist-dot-treelist-dot-calchitinfo-x28-system-dot-drawing-dot-point-x29.md
Returns information about the Tree List’s elements which are located at the specified point.
Namespace : DevExpress.XtraTreeList
Assembly : DevExpress.XtraTreeList.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList
public TreeListHitInfo CalcHitInfo(
Point pt
)
Public Function CalcHitInfo(
pt As Point
) As TreeListHitInfo
| Name | Type | Description |
|---|---|---|
| pt | Point |
A Point structure which specifies test point coordinates relative to the Tree List’s top-left corner.
|
| Type | Description |
|---|---|
| TreeListHitInfo |
A TreeListHitInfo object which contains information about the Tree List’s elements located at the test point.
|
Use the CalcHitInfo method to determine which element is located at a specified point. For instance, this can be used when handling the Tree List’s Click event to determine which element was clicked. In such instances, pass the current mouse pointer’s coordinates as the method’s parameter.
The code below obtains the name of the element located under the mouse pointer. The MouseMove event is handled to track mouse pointer movement.
using DevExpress.XtraTreeList;
//...
private void treeList1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) {
TreeListHitInfo hi = treeList1.CalcHitInfo(new Point(e.X, e.Y));
string elementName = hi.HitInfoType.ToString();
//...
}
Imports DevExpress.XtraTreeList
'...
Private Sub TreeList1_MouseMove(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles TreeList1.MouseMove
Dim hi As TreeListHitInfo = TreeList1.CalcHitInfo(New Point(e.X, e.Y))
Dim ElementName As String = hi.HitInfoType.ToString()
' ...
End Sub
The following code snippets (auto-collected from DevExpress Examples) contain references to the CalcHitInfo(Point) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-tokenedit-dropdown-with-treelist/CS/TokenEditTest/CustomTokenEditDropDownControl.cs#L73
void OnTreeListDoubleClick(object sender, EventArgs e) {
TreeListHitInfo hi = TreeList.CalcHitInfo(TreeList.PointToClient(Control.MousePosition));
if(hi.HitInfoType == HitInfoType.Cell && GetSelectedDataItem() is TreeListLeaf) {
drag-drop-grid-rows-to-treelist/CS/DragAndDropRows/Form1.cs#L92
Point pt = treeList.PointToClient(hitPoint);
var ht = treeList.CalcHitInfo(pt);
TreeListNode destNode = ht.Node;
winforms-spreadsheetcontrol-api-part1/CS/SpreadsheetControl/Form1.cs#L149
TreeList tree = sender as TreeList;
TreeListHitInfo hitInfo = tree.CalcHitInfo(tree.PointToClient(Control.MousePosition));
if (hitInfo.Node != null)
winforms-treelist-customize-cell-tooltip/CS/Form1.cs#L24
TreeList tree = (TreeList)e.SelectedControl;
TreeListHitInfo hit = tree.CalcHitInfo(e.ControlMousePosition);
if(hit.HitInfoType == HitInfoType.Cell) {
winforms-tokenedit-dropdown-with-treelist/VB/TokenEditTest/CustomTokenEditDropDownControl.vb#L81
Private Sub OnTreeListDoubleClick(ByVal sender As Object, ByVal e As EventArgs) Handles treeList_Renamed.DoubleClick
Dim hi As TreeListHitInfo = TreeList.CalcHitInfo(TreeList.PointToClient(Control.MousePosition))
If hi.HitInfoType = HitInfoType.Cell AndAlso TypeOf GetSelectedDataItem() Is TreeListLeaf Then
drag-drop-grid-rows-to-treelist/VB/DragAndDropRows/Form1.vb#L90
Dim pt As Point = treeList.PointToClient(hitPoint)
Dim ht = treeList.CalcHitInfo(pt)
Dim destNode As TreeListNode = ht.Node
winforms-spreadsheetcontrol-api-part1/VB/SpreadsheetControl/Form1.vb#L142
Dim tree As TreeList = TryCast(sender, TreeList)
Dim hitInfo As TreeListHitInfo = tree.CalcHitInfo(tree.PointToClient(Control.MousePosition))
If hitInfo.Node IsNot Nothing Then
winforms-treelist-customize-cell-tooltip/VB/Form1.vb#L24
Dim tree As TreeList = CType(e.SelectedControl, TreeList)
Dim hit As TreeListHitInfo = tree.CalcHitInfo(e.ControlMousePosition)
If hit.HitInfoType = HitInfoType.Cell Then
See Also