Back to Devexpress

ColumnView.FocusedColumn Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-columnview-dcca7012.md

latest8.6 KB
Original Source

ColumnView.FocusedColumn Property

Gets or sets the focused column/card field (in CardView and LayoutView Views).

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
[Browsable(false)]
public virtual GridColumn FocusedColumn { get; set; }
vb
<Browsable(False)>
Public Overridable Property FocusedColumn As GridColumn

Property Value

TypeDescription
GridColumn

A GridColumn object or descendant representing the currently focused column/card field.

|

Remarks

Use the FocusedColumn property to access the currently focused column/card field , or to set focus to a specific column/card field. When the FocusedColumn property’s value is changed, the ColumnView.FocusedColumnChanged event is raised.

To access the focused row/card, use the ColumnView.FocusedRowHandle property.

After moving focus between cards in LayoutViews and CardViews via the FocusedRowHandle inherited property, the ColumnView.FocusedColumn property is automatically set to null. In this instance, you may want to manually move focus to a specific card field via the FocusedColumn property after changing the FocusedRowHandle.

For more information, see the Columns topic.

Note

Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the FocusedColumn member must not be invoked for these Views. The FocusedColumn member can only be used with Views that display real data within the Grid Control. Use the following methods to access these Views with which an end user interacts at runtime.

Example

The example shows how to move focus to a specific column at runtime.

csharp
advBandedGridView1.FocusedColumn = advBandedGridView1.Columns["Country"];
vb
AdvBandedGridView1.FocusedColumn = AdvBandedGridView1.Columns("Country")

The following code snippets (auto-collected from DevExpress Examples) contain references to the FocusedColumn 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-show-error-icons/CS/Form1.cs#L72

csharp
{
    string error = GetError(gridView1.GetFocusedValue(), gridView1.FocusedRowHandle, gridView1.FocusedColumn);
    if (error == string.Empty) return;

winforms-grid-move-cell-using-drag-drop/CS/Classes/GridViewHelper.cs#L97

csharp
if (gridHI.HitTest == GridHitTest.RowCell)
    if (gridHI.RowHandle == (view as GridView).FocusedRowHandle && gridHI.Column == (view as GridView).FocusedColumn)
       (view as GridView).GridControl.Cursor = Cursors.SizeAll;

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-show-error-icons/VB/Form1.vb#L80

vb
Private Sub gridView1_ShownEditor(ByVal sender As Object, ByVal e As EventArgs) Handles gridView1.ShownEditor
    Dim [error] As String = GetError(gridView1.GetFocusedValue(), gridView1.FocusedRowHandle, gridView1.FocusedColumn)
    If [error] = String.Empty Then

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

vb
If gridHI.HitTest = GridHitTest.RowCell Then
    If gridHI.RowHandle = (TryCast(view, GridView)).FocusedRowHandle AndAlso gridHI.Column Is (TryCast(view, GridView)).FocusedColumn Then
       TryCast(view, GridView).GridControl.Cursor = Cursors.SizeAll

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

Columns

FocusedColumnChanged

FocusedRowHandle

ColumnView Class

ColumnView Members

DevExpress.XtraGrid.Views.Base Namespace