Skip to main content
A newer version of this page is available. .

LayoutControl.CalcHitInfo(Point) Method

Returns information on the layout elements located at the specified point.

Namespace: DevExpress.XtraLayout

Assembly: DevExpress.XtraLayout.v19.1.dll

Declaration

public BaseLayoutItemHitInfo CalcHitInfo(
    Point hitPoint
)

Parameters

Name Type Description
hitPoint Point

A Point structure which specifies the test point coordinates relative to the layout controls top-left corner.

Returns

Type Description
BaseLayoutItemHitInfo

A BaseLayoutItemHitInfo object which contains information about the layout elements located at the test point.

Remarks

Use the CalcHitInfo method to determine which element is located at the specified point. For instance, this can be used when handling the layout control’s Click event to determine which element was clicked. In such cases, pass the current mouse pointer’s coordinates as the method’s parameter.

Example

This example shows how to focus a control within a LayoutControl when a corresponding label is clicked. In the MouseDown event handler, the CalcHitInfo method is used to access a layout item at the current mouse position. If the layout item has a control, the control is focused.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraLayout;
using DevExpress.XtraLayout.HitInfo;


namespace LayoutControl_CalcHitInfo {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void layoutControl1_MouseDown(object sender, MouseEventArgs e) {
            LayoutControl lc = sender as LayoutControl;
            BaseLayoutItemHitInfo hi = lc.CalcHitInfo(e.Location);
            LayoutControlItem currentItem = hi.Item as LayoutControlItem;
            if (currentItem == null || hi.HitType != LayoutItemHitTest.TextArea) return;
            if(currentItem.Control != null)
                currentItem.Control.Focus();
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference 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.

See Also