Hi ,Thanks to Response. I have checked the solution provided by you. I applied validation rule on Row for Second column from left side of sfdatagrid and set the debug point to DataGrid_RowValidating event.I am still facing the same issue, when i am pressing tab key when focus is on left most column then "DataGrid_RowValidating " event getting raised before navigating to next left column.I have Attached the Modified Solution. Please Check and please set the cell in edit mode before pressing tabThanks RegardsYogendra
Attachment: SelectionDemo_8fbcd71f.zip
public class GridCellSelectionControllerExt : GridCellSelectionController
{
public GridCellSelectionControllerExt(SfDataGrid dataGrid) : base (dataGrid)
{
}
protected override void ProcessKeyDown(KeyEventArgs args)
{
if (args.Key == Key.Tab)
{
int rowIndex, columnIndex;
if (CurrentCellManager.CurrentRowColumnIndex.RowIndex <= this.DataGrid.GetHeaderIndex() && !(this.DataGrid is DetailsViewDataGrid))
return;
var rowColumnIndex = this.CurrentCellManager.CurrentRowColumnIndex;
if (!args.Handled)
{
rowIndex = CurrentCellManager.CurrentRowColumnIndex.RowIndex;
columnIndex = CurrentCellManager.CurrentRowColumnIndex.ColumnIndex;
bool isLastColumnIndex = columnIndex == this.DataGrid.Columns.Count;
object isValidationRaised = null;
if (isLastColumnIndex)
{
var vaildationHelper = this.DataGrid.GetValidationHelper();
var raiseValidateMethod = vaildationHelper.GetType().GetMethod("RaiseRowValidate", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
isValidationRaised = raiseValidateMethod.Invoke(vaildationHelper, new object[] { CurrentCellManager.CurrentRowColumnIndex });
}
if (isValidationRaised != null && !(bool)isValidationRaised)
{
args.Handled = true;
return;
}
if (isLastColumnIndex)
{
int index = rowIndex + 1;
if (index > this.DataGrid.View.Records.Count)
index = 1;
rowColumnIndex = new RowColumnIndex(index, 1);
}
else
{
rowColumnIndex = new RowColumnIndex(rowIndex, columnIndex + 1);
}
this.DataGrid.SelectionController.MoveCurrentCell(rowColumnIndex,true);
}
}
else
{
base.ProcessKeyDown(args);
}
}
} |