How can I most efficiently set up a grid so that pressing enter will move focus the next row, first editable cell?
Here is a code sample that demonstrates how to add a custom key-action mapping, and how to use the PerformAction method to do what you described here. Note that this is not necessarily a robust solution to your specific problem, but rather demonstrates some of the approaches you can take.
// Add a mapping that activates the next rowthis.ultraGrid.KeyActionMappings.Add( new GridKeyActionMapping( Keys.Enter, UltraGridAction.NextRow, 0, UltraGridState.Row, SpecialKeys.All, 0) );
// Handle AfterPerformAction, and enter edit mode on the first cell// after the 'NextRow' action is performed.AfterUltraGridPerformActionEventHandler handler =delegate( object sender, AfterUltraGridPerformActionEventArgs args ){ if ( args.UltraGridAction == UltraGridAction.NextRow ) { this.ultraGrid.ActiveRow.Cells[0].Activate(); this.ultraGrid.PerformAction(UltraGridAction.EnterEditMode); }};
this.ultraGrid.AfterPerformAction += handler;
Instead of using
this.ultraGrid.ActiveRow.Cells[0].Activate(); this.ultraGrid.PerformAction(UltraGridAction.EnterEditMode);
I have hidden and rearranged columns. How do I ensure placement into the first visible, editable cell?
Hi Mike;
mike i m using ultragird and keydown event to move the focus to the next row of the same column.
it works fine. but when i drag the column to the header of the group, it works for only one group. it doesn't move to the next group automatically.
following is the code for moving focus to the same cell of the next row:
private void dgvSaleCustomers_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Down: case Keys.Enter: this.dgvSaleCustomers.PerformAction(UltraGridAction.ExitEditMode, false, false); UltraGridBand b = this.dgvSaleCustomers.DisplayLayout.Bands[0];
if (dgvSaleCustomers.ActiveRow.HasNextSibling(true)) { UltraGridRow nextRow = dgvSaleCustomers.ActiveRow.GetSibling(SiblingRow.Next, true); dgvSaleCustomers.ActiveCell = nextRow.Cells[dgvSaleCustomers.ActiveCell.Column]; e.Handled = true; this.dgvSaleCustomers.PerformAction(UltraGridAction.EnterEditMode, false, false); } break;
Please advice. waiting for your reply!!!!!!!!
GetFirstVisibleCol is a method on the band.
Thanks.
Looks like there is no "GetFirstVisibleColumn" though. Instead:
GetRelatedVisibleColumn(VisibleRelation.First)
You can use the GetFirstVisibleColumn method on the band to get the first visible column. You could then have to loop through the columns until you find one that is editable using GetRelatedVisibleColumn on the column.