public class SfDataGridExt : SfDataGrid
{
public SfDataGridExt()
: base()
{
}
protected override void OnTextInput(TextCompositionEventArgs e)
{
if (!SelectionController.CurrentCellManager.HasCurrentCell)
{
base.OnTextInput(e);
return;
}
//Get the Current Row and Column index from the CurrentCellManager
var rowColumnIndex = SelectionController.CurrentCellManager.CurrentRowColumnIndex;
RowGenerator rowGenerator = this.RowGenerator;
//Get the row from the Row index
var dataRow = rowGenerator.Items.FirstOrDefault(item => item.RowIndex == rowColumnIndex.RowIndex);
//Check whether the dataRow is null or not and the type as DataRow
if (dataRow != null && dataRow is DataRow)
{
//Get the column from the VisibleColumn collection based on the column index
var dataColumn = dataRow.VisibleColumns.FirstOrDefault(column => column.ColumnIndex == rowColumnIndex.ColumnIndex);
//Convert the input text to char type
char text;
char.TryParse(e.Text, out text);
//Skip if the column is not GridCurrencyColumn and the column is not already in editing
//Allow Editing only pressed letters digits and dot(.) sign key
if (dataColumn != null && (dataColumn.GridColumn is GridCurrencyColumn) && (e.Text.Equals(".") || char.IsLetterOrDigit(text)) && !dataColumn.IsEditing && SelectionController.CurrentCellManager.BeginEdit())
dataColumn.Renderer.PreviewTextInput(e);
}
base.OnTextInput(e);
}
} |
Thank you,
it's a good solution but it still does not completely resolve my question.
See attached video to better understand.
Ciao,
Silvio Scattaglia
public class SfDataGridExt : SfDataGrid
{
public SfDataGridExt()
: base()
{
}
protected override void OnTextInput(TextCompositionEventArgs e)
{
if (!SelectionController.CurrentCellManager.HasCurrentCell)
{
base.OnTextInput(e);
return;
}
//Get the Current Row and Column index from the CurrentCellManager
var rowColumnIndex = SelectionController.CurrentCellManager.CurrentRowColumnIndex;
RowGenerator rowGenerator = this.RowGenerator;
//Get the row from the Row index
var dataRow = rowGenerator.Items.FirstOrDefault(item => item.RowIndex == rowColumnIndex.RowIndex);
//Check whether the dataRow is null or not and the type as DataRow
if (dataRow != null && dataRow is DataRow)
{
//Get the column from the VisibleColumn collection based on the column index
var dataColumn = dataRow.VisibleColumns.FirstOrDefault(column => column.ColumnIndex == rowColumnIndex.ColumnIndex);
//Convert the input text to char type
char text;
char.TryParse(e.Text, out text);
//Skip if the column is not GridCurrencyColumn and the column is not already in editing
//Allow Editing only pressed letters digits and dot(.) sign key
var decimalSeparator = (dataColumn.GridColumn as GridCurrencyColumn).CurrencyDecimalSeparator;
if (dataColumn != null && (dataColumn.GridColumn is GridCurrencyColumn) && (e.Text.Equals(decimalSeparator) || char.IsLetterOrDigit(text)) && !dataColumn.IsEditing && SelectionController.CurrentCellManager.BeginEdit())
dataColumn.Renderer.PreviewTextInput(e);
}
base.OnTextInput(e);
}
} |
You can must follow the key which has been used for the CurrencyDecimalSeparator to enter the edit-mode in application avoid usage of others. |
Thank you for your help.