BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
//Event Triggering
this.gridGroupingControl1.CurrentRecordContextChange += GridGroupingControl1_CurrentRecordContextChange;
//Event Customization
private void GridGroupingControl1_CurrentRecordContextChange(object sender, CurrentRecordContextChangeEventArgs e)
{
int colIndex = this.gridGroupingControl1.TableControl.CurrentCell.ColIndex;
//To move the right cell when pressing Enter on AddNewRecordRow and restrict the new record being added when enter the value until last column
if (e.Action == Syncfusion.Grouping.CurrentRecordAction.EndEditCalled && e.Table.AddNewRecord.IsCurrent
&& colIndex != this.gridGroupingControl1.TableControl.TableDescriptor.Columns.Count)
{
e.Cancel = true;
this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(this.gridGroupingControl1.TableControl.CurrentCell.RowIndex, colIndex + 1, GridSetCurrentCellOptions.SetFocus);
}
if (e.Action == Syncfusion.Grouping.CurrentRecordAction.EndEditCalled && e.Table.AddNewRecord.IsCurrent
&& colIndex == this.gridGroupingControl1.TableControl.TableDescriptor.Columns.Count)
{
//Validate the current record values and defines whether it can be added or not.
if ((int)e.Record.GetRecord().GetValue("CategoryID") > 100)
{
e.Cancel = true;
}
}
} |
Sample link: http://www.syncfusion.com/downloads/support/forum/130099/ze/DataGrid_20151195234678
//Event triggering
this.gridDataBoundGrid1.CurrentCellKeyDown += GridDataBoundGrid1_CurrentCellKeyDown1;
//Event customization
private void GridDataBoundGrid1_CurrentCellKeyDown1(object sender, KeyEventArgs e)
{
if(e.KeyCode==Keys.Enter)
{
GridCurrentCell currentCell = gridDataBoundGrid1.CurrentCell;
if (currentCell.ColIndex==this.gridDataBoundGrid1.GridBoundColumns.Count)
{
if (currentCell.RowIndex == this.gridDataBoundGrid1.Binder.RecordCount)
//To move the first cell if the current cell is last column of the last row
currentCell.MoveTo(1, 1);
else
//To move the first column of next row
currentCell.MoveTo(currentCell.RowIndex + 1, 1);
e.Handled = true;
}
}
}
//Event triggering
this.gridDataBoundGrid1.CurrentCellEditingComplete += GridDataBoundGrid1_CurrentCellEditingComplete;
//Event customization
private void GridDataBoundGrid1_CurrentCellEditingComplete(object sender, EventArgs e)
{
//Code to perform
} |
//Custom DataBoundGrid class
public class CustomDataBoundGrid: GridDataBoundGrid
{
protected override void OnCurrentCellEditingComplete(EventArgs e)
{
base.OnCurrentCellEditingComplete(e);
///
///Code to perform
///
}
}
//Event Triggering
this.customGrid.CurrentCellEditingComplete += CustomGrid_CurrentCellEditingComplete;
//Event customization
private void CustomGrid_CurrentCellEditingComplete(object sender, EventArgs e)
{
//Code to perform
} |