Posted 17 December 2021, 3:32 am EST
assembly name C1.WPF.DataGrid.4.5.2 version 4.5.20212.747
c1Datagrid c1:DataGridDateTimeColumn keyboard input behavior difference to c1:DataGridTextColumn
workflow with DataGridTextColumn:
-one click on Textcolumn
-typing the character ‘2’
result:
the character ‘2’ is immediately inserted
workflow with DataGridDateTimeColumn:
-one click on DataGridDateTimeColumn
-typing the character ‘2’
result:
the character ‘2’ is NOT inserted only the edit mode started.
problem:
i have to type the 2 again.
question:
how do i achieve the same behavior like DataGridTextColumn with the DataGridDateTimeColumn ?
i tried:
-catch event previewtextinput on cell
-start cell edit mode to get the edit controls
-resend the previewtextinput character to the C1MaskedTextBox (child?) from the c1DateTimePicker
-but i cannot find the C1MaskedTextBox in the visual tree.
sample project attachted
private void DataGridCellPresenter_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
var dgcp = sender as DataGridCellPresenter;
if(dgcp.Cell.Column is DataGridDateTimeColumn)
{
if (!dgcp.Cell.IsEditing)
{
dgcp.DataGrid.BeginEdit(dgcp.Cell);
var editCellPresenter = dgcp.DataGrid.CurrentCell.Presenter as FrameworkElement;
var mtb = FindChild<C1.WPF.C1MaskedTextBox>(editCellPresenter);
//problem here: C1MaskedTextBox is null
if (mtb != null)
{
TextCompositionManager.StartComposition(new TextComposition(InputManager.Current, mtb, e.Text));
}
}
}
}
greetings from germany