Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
145391 | Jun 19,2019 08:03 PM UTC | Apr 20,2020 08:36 AM UTC | WinForms | 6 |
![]() |
Tags: SfDataGrid |
sfDataGrid.SelectionUnit = SelectionUnit.Row;
sfDataGrid.SelectionController = new RowSelectionControllerExt(sfDataGrid);
public class RowSelectionControllerExt : RowSelectionController
{
SfDataGrid sfDataGrid;
public RowSelectionControllerExt(SfDataGrid sfDataGrid)
: base(sfDataGrid)
{
this.sfDataGrid = sfDataGrid;
}
protected override void ProcessEnterKey()
{
AddingNewRow();
base.ProcessEnterKey();
}
protected override voidProcessArrowKeysForSingleMultipleSelection(KeyEventArgs args)
{
if (args.KeyCode == Keys.Tab)
AddingNewRow();
base.ProcessArrowKeysForSingleMultipleSelection(args);
}
private void AddingNewRow()
{
if (DataGrid.RowCount - 1 == DataGrid.CurrentCell.RowIndex && DataGrid.ColumnCount - 1 == DataGrid.CurrentCell.ColumnIndex)
{
sfDataGrid.View.AddNew();
sfDataGrid.View.CommitNew();
}
}
} |
sfDataGrid.SelectionUnit = SelectionUnit.Cell;
sfDataGrid.SelectionController = new CellSelectionControllerExt(sfDataGrid);
public class CellSelectionControllerExt : CellSelectionController
{
SfDataGrid sfDataGrid;
public CellSelectionControllerExt(SfDataGrid sfDataGrid)
: base(sfDataGrid)
{
this.sfDataGrid = sfDataGrid;
}
protected override void ProcessEnterKey()
{
AddingNewRow();
base.ProcessEnterKey();
}
protected override voidProcessArrowKeysForSingleMultipleSelection(KeyEventArgs args)
{
AddingNewRow();
base.ProcessArrowKeysForSingleMultipleSelection(args);
}
private void AddingNewRow()
{
if (DataGrid.RowCount - 1 == DataGrid.CurrentCell.RowIndex && DataGrid.ColumnCount - 1 == DataGrid.CurrentCell.ColumnIndex)
{
sfDataGrid.View.AddNew();
sfDataGrid.View.CommitNew();
}
}
} |
I want to do two things is SfDataGrid, winform, C#Jagadeesan Pichaimuthu [Syncfusion] answered how to do part 1 above (add new row if you hit enter/tab key in last column and row of SFDataGrid and know I need to do how to both #1 AND #2 not just #1
- Add a new row automaticaly after user hit's the tab or enter key when they are in the last column and last row of SFDataGrid.
- AND I want to enter key to function as a tab key for ALL cells & rows in SFDataGrid
I am attaching a zip of my source code fileSee code in RowSelectionControllerExt.cs which does Request #1 but not #2New selection controler is set in Form1_load()sfDataGrid1.SelectionController = new RowSelectionControllerExt(sfDataGrid1);Thanks!
Attachment: v2_get_value_by_row_column_44264d85.7z
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.