I have xamWebGrid binding to a list and I would like to set focus to first row when application is launched, I have tried different ways, but no luck. Microsoft datagrid has a very simple way to do it. Can someone please help. Thanks
<igGrid:XamWebGrid x:Name="_dgEventsList" AutoGenerateColumns="False" ColumnWidth="*" Height="300" Width="500" ItemsSource="{Binding EventList}"> <igGrid:XamWebGrid.SelectionSettings> <igGrid:SelectionSettings CellClickAction="SelectRow" RowSelection="Single"></igGrid:SelectionSettings> </igGrid:XamWebGrid.SelectionSettings> <igGrid:XamWebGrid.Columns> <igGrid:TextColumn Key="EventName" Width="200" HeaderText="Name"/> <igGrid:TextColumn Key="EventDesc" Width="*" HeaderText="Description"/> <igGrid:TextColumn Key="AppModule" Visibility="Collapsed" HeaderText="AppModule"/> </igGrid:XamWebGrid.Columns> </igGrid:XamWebGrid>
Hi,
In the Grid's Loaded event, you can set the ActiveCell to the first cell in the first row.
grid.ActiveCell = grid.Rows[0].Cells[0];
-SteveZ
Hi SteveZ,
Thanks for the quick answer, This does set focus in the first column of the row, but doesn't select a Row, which causes not to fire "SelectedRowsCollectionChanged" event. Is there any way to get fire automatically or do I need to write a code to handle manually.
Thanks
How can i show selected row always on top in datagrid,
Thanks,
Nandu
So we're talking about 2 different things. The grid supports selection and activation.
Activation refers to the ActiveCell, in which there can only be on Active cell at any time.
Selection, is supported for rows, cells and columns, and allows multiple items to be selected at any given time.
To select a row, you have a couple of options:
((Row)grid.Row[0]).IsSelected = true;
or
grid.SelectionSettings.SelectedRows.Add((Row)grid.Row[0]);