Back to Devexpress

PivotGridControl.CalcHitInfo(Point) Method

windowsforms-devexpress-dot-xtrapivotgrid-dot-pivotgridcontrol-dot-calchitinfo-x28-system-dot-drawing-dot-point-x29.md

latest5.5 KB
Original Source

PivotGridControl.CalcHitInfo(Point) Method

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

Namespace : DevExpress.XtraPivotGrid

Assembly : DevExpress.XtraPivotGrid.v25.2.dll

NuGet Package : DevExpress.Win.PivotGrid

Declaration

csharp
public PivotGridHitInfo CalcHitInfo(
    Point hitPoint
)
vb
Public Function CalcHitInfo(
    hitPoint As Point
) As PivotGridHitInfo

Parameters

NameTypeDescription
hitPointPoint

A Point structure which specifies the test point coordinates relative to the Pivot Grid Control’s top-left corner.

|

Returns

TypeDescription
PivotGridHitInfo

A PivotGridHitInfo object which contains information about the grid 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 Pivot Grid 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.

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-pivot-grid-draw-a-custom-element-on-mouse-hover/CS/WindowsApplication73/Form1.cs#L61

csharp
mousePos = Point.Empty;
PivotGridHitInfo info = pivotGridControl1.CalcHitInfo(e.Location);
if (info.HitTest == PivotGridHitTest.Value)

pivot-grid-winforms-provide-custom-date-time-group-intervals-and-preserve-correct-sort-order/CS/WindowsApplication21/Form1.cs#L61

csharp
private void pivotGridControl1_MouseClick(object sender, MouseEventArgs e) {
    PivotGridHitInfo hitInfo = pivotGridControl1.CalcHitInfo(e.Location);
    if (hitInfo.HitTest == PivotGridHitTest.Value && hitInfo.ValueInfo != null)

win-designer-pivot-as-master-filter/CS/DesignerSample/Form1.cs#L37

csharp
PivotGridControl pivot = sender as PivotGridControl;
PivotGridHitInfo hi = pivot.CalcHitInfo(e.Location);
skipFiltering = (hi.ValueInfo != null && hi.ValueInfo.ValueHitTest == PivotGridValueHitTest.ExpandButton);

winforms-pivot-grid-draw-a-custom-element-on-mouse-hover/VB/WindowsApplication73/Form1.vb#L59

vb
mousePos = Point.Empty
Dim info As PivotGridHitInfo = pivotGridControl1.CalcHitInfo(e.Location)
If info.HitTest = PivotGridHitTest.Value Then

pivot-grid-winforms-provide-custom-date-time-group-intervals-and-preserve-correct-sort-order/VB/WindowsApplication21/Form1.vb#L69

vb
Private Sub pivotGridControl1_MouseClick(ByVal sender As Object, ByVal e As MouseEventArgs)
    Dim hitInfo As PivotGridHitInfo = pivotGridControl1.CalcHitInfo(e.Location)
    If hitInfo.HitTest = PivotGridHitTest.Value AndAlso hitInfo.ValueInfo IsNot Nothing Then dataGridView1.DataSource = hitInfo.ValueInfo.CreateDrillDownDataSource()

win-designer-pivot-as-master-filter/VB/DesignerSample/Form1.vb#L39

vb
Dim pivot As PivotGridControl = TryCast(sender, PivotGridControl)
Dim hi As PivotGridHitInfo = pivot.CalcHitInfo(e.Location)
skipFiltering = (hi.ValueInfo IsNot Nothing AndAlso hi.ValueInfo.ValueHitTest = PivotGridValueHitTest.ExpandButton)

See Also

PivotGridControl Class

PivotGridControl Members

DevExpress.XtraPivotGrid Namespace