Hi
I wanted to catch 'enter' in a text column to add a new line to the text (since TextColumn doesn't support 'AcceptsReturn') so I added a KeyDown handler to the grid and found that the handler isn't called for Key.Enter.
It is, however, called for Key.Enter when catching KeyDown on a TextBlock in a TemplateColumn. which is what I'm doing now, but it seems an odd restriction.
James
Nikolay ,
How to do changes in Column2 (say Quantity) should do calculation on Total column
Product - Price - Quantity - Total
User will enter Quantity and Tab or focus lost , then TOTAL must be calcualated Total =(Price * Quantity) for each row changed by User. Thank how to do in XAMGrid
Hi,
The XamGrid handles KeyDown event when the Enter key is press.
For the case that you describe you can use a TemplateColumn like that:
... <ig:TemplateColumn Key="String"> <ig:TemplateColumn.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding String}" /> </DataTemplate> </ig:TemplateColumn.ItemTemplate> <ig:TemplateColumn.EditorTemplate> <DataTemplate> <TextBox Text="{Binding String, Mode=TwoWay}" KeyDown="TextBox_KeyDown" /> </DataTemplate> </ig:TemplateColumn.EditorTemplate> </ig:TemplateColumn> ...
... private void TextBox_KeyDown(object sender, KeyEventArgs e) { TextBox source = (TextBox)sender; if (e.Key == Key.Enter) { if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) { this.XGrid.ExitEditMode(false); } else { int start = source.SelectionStart; source.Text = source.Text.Insert(source.SelectionStart, Environment.NewLine); source.SelectionStart = start + Environment.NewLine.Length; e.Handled = true; } } } ...
I hope that this will help you