Back to Devexpress

GridHitInfo.Column Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-viewinfo-dot-gridhitinfo.md

latest6.6 KB
Original Source

GridHitInfo.Column Property

Gets or sets a column located under the test point.

Namespace : DevExpress.XtraGrid.Views.Grid.ViewInfo

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
public virtual GridColumn Column { get; set; }
vb
Public Overridable Property Column As GridColumn

Property Value

TypeDescription
GridColumn

A GridColumn object representing the column that contains the test point.

|

Remarks

Use the Column property to obtain the column whose element is under the test point. Please refer to the Column topic for the list of elements within a column. If the test point is over a visual element which does not belong to any column, the Column property returns null ( Nothing in Visual Basic).

To determine the type of a particular visual element under the test point, read the GridHitInfo.HitTest property value.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Column property.

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-grid-move-cell-using-drag-drop/CS/Classes/GridViewHelper.cs#L50

csharp
{
    object val = (view as GridView).GetRowCellValue(gridHI.RowHandle, gridHI.Column);
    if (val == null || val.ToString() == string.Empty) return;

winforms-grid-custom-button-in-column-header/CS/WindowsApplication3/ColumnHeaderExtender.cs#L54

csharp
if(hitInfo.HitTest != GridHitTest.Column) return;
GridColumn column = hitInfo.Column;
if(IsButtonRect(e.Location, column)) {

winforms-grid-multi-cell-editing/CS/MultiSelectionEditingHelper.cs#L35

csharp
{
    view.FocusedColumn = hi.Column;
    DXMouseEventArgs.GetMouseArgs(e).Handled = true;

winforms-grid-toggle-checkbox-state-with-one-click/CS/Form1.cs#L63

csharp
{
    view.FocusedColumn = hi.Column;
    view.FocusedRowHandle = hi.RowHandle;

winforms-grid-select-rows-using-mouse-without-ctrl/CS/MultiSelectionHelper.cs#L48

csharp
_GridView.FocusedRowHandle = hi.RowHandle;
_GridView.FocusedColumn = hi.Column;
_GridView.InvertRowSelection(hi.RowHandle);

winforms-grid-move-cell-using-drag-drop/VB/Classes/GridViewHelper.vb#L44

vb
If gridHI.HitTest = GridHitTest.RowCell Then
    Dim val As Object = (TryCast(view, GridView)).GetRowCellValue(gridHI.RowHandle, gridHI.Column)
    If val Is Nothing OrElse val.ToString() = String.Empty Then

winforms-grid-custom-button-in-column-header/VB/WindowsApplication3/ColumnHeaderExtender.vb#L56

vb
End If
Dim column As GridColumn = hitInfo.Column
If IsButtonRect(e.Location, column) Then

winforms-grid-multi-cell-editing/VB/MultiSelectionEditingHelper.vb#L31

vb
If view.FocusedRowHandle = hi.RowHandle Then
    view.FocusedColumn = hi.Column
    DXMouseEventArgs.GetMouseArgs(e).Handled = True

winforms-grid-toggle-checkbox-state-with-one-click/VB/Form1.vb#L56

vb
Private Shared Sub ProcessCheckClick(ByVal e As MouseEventArgs, ByVal view As GridView, ByVal hi As GridHitInfo)
    view.FocusedColumn = hi.Column
    view.FocusedRowHandle = hi.RowHandle

winforms-grid-select-rows-using-mouse-without-ctrl/VB/MultiSelectionHelper.vb#L42

vb
_GridView.FocusedRowHandle = hi.RowHandle
_GridView.FocusedColumn = hi.Column
_GridView.InvertRowSelection(hi.RowHandle)

See Also

HitTest

Column

Grid Columns

GridHitInfo Class

GridHitInfo Members

DevExpress.XtraGrid.Views.Grid.ViewInfo Namespace