DataControlBase.CurrentColumn Property
Gets or sets the focused column.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v24.2.Core.dll
NuGet Package: DevExpress.Wpf.Grid.Core
Declaration
Property Value
Type | Description |
---|---|
ColumnBase | A GridColumn object that represents the focused column. |
Remarks
The CurrentColumn property returns null if the DataViewBase.NavigationStyle property isn’t set to GridViewNavigationStyle.Cell.
To learn more, see Focusing.
Example
This example shows how to identify a data cell with the specified value and focus it. To do this, click the Focus Cell button.
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<dxg:GridControl Name="grid" AutoGenerateColumns="AddNew">
<dxg:GridControl.View>
<dxg:TableView x:Name="view" AutoWidth="True" FadeSelectionOnLostFocus="False"/>
</dxg:GridControl.View>
</dxg:GridControl>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<TextBlock Text="Unit Price:" TextAlignment="Right" Padding="4"/>
<TextBox x:Name="textBox" Width="50" Margin="0,0,5,0" HorizontalAlignment="Left"/>
<Button Content="Focus Cell" HorizontalAlignment="Left" Click="FocusCell"/>
</StackPanel>
</Grid>
void FocusCell(object sender, RoutedEventArgs e) {
if (!double.TryParse(textBox.Text, out double textValue))
return;
var rowHandle = grid.FindRowByValue(grid.Columns[nameof(Product.UnitPrice)], textValue);
if (rowHandle == DataControlBase.InvalidRowHandle)
return;
grid.CurrentColumn = grid.Columns[nameof(Product.UnitPrice)];
view.FocusedRowHandle = rowHandle;
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CurrentColumn 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.