DataGridTextBoxColumn Event

W

Wild Goose

Hi all, Need some help here.

I have created my own DataGridTextBoxColumn and
DataGridTableStyle and have bound this to the DataGrid.
I am trying to capture the text changed event on a
DataGridTextBoxColumn. I need an event to be triggered
when the user either edit's text in the textbox, or tabs
on textbox, hits enter key, or presses up/down/right/left
keys.
I tried capturing the LostFocus & Leave events on the
DataGridTextBoxColumn. These events fires only if the
users hits tab on the column. It does not fire on hitting
enter key.
The TextChanged event fires for each character typed,
which probably I think I should be using to check for
integrity of data, but then how do I tell once the user
has finished typing.

Can anyone help me in this context.

Let me know if you still need more explanation.

Thanks
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi,

You will need to override the following methods in the DataGrid itself to
tap into keyboard navigation:

ProcessDialogKey - this method will be called when no cell is being edited
ProcessKeyPreview - this method will be called whe a cell IS being edited to
separate control keys strokes as Tab or Arrows from regular alpha-numeric
keystrokes that should be treated as user input.
 
W

WildGooose

Thanks everybody.

And special thanks to Dmitriy Lapshin. I infact tried all
way of implementing this ...overriding IsInputKey. But,
finally realized that it works on a plain TextBox and not
within a TextBox with a DataGrid.

Thanks once again Dmitriy.

-----Original Message-----
Hi,

You will need to override the following methods in the DataGrid itself to
tap into keyboard navigation:

ProcessDialogKey - this method will be called when no cell is being edited
ProcessKeyPreview - this method will be called whe a cell IS being edited to
separate control keys strokes as Tab or Arrows from regular alpha-numeric
keystrokes that should be treated as user input.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Wild Goose said:
Hi all, Need some help here.

I have created my own DataGridTextBoxColumn and
DataGridTableStyle and have bound this to the DataGrid.
I am trying to capture the text changed event on a
DataGridTextBoxColumn. I need an event to be triggered
when the user either edit's text in the textbox, or tabs
on textbox, hits enter key, or presses up/down/right/left
keys.
I tried capturing the LostFocus & Leave events on the
DataGridTextBoxColumn. These events fires only if the
users hits tab on the column. It does not fire on hitting
enter key.
The TextChanged event fires for each character typed,
which probably I think I should be using to check for
integrity of data, but then how do I tell once the user
has finished typing.

Can anyone help me in this context.

Let me know if you still need more explanation.

Thanks

.
 
W

WildGooose

Dmitriy -

I think I have a problem. I implemented ProcessKeyPreview,
and it seems to be capturing only 'Enter' key. Tab, and
directional keys are not being captured. I have also
implemented KeyPress and KeyDown methods to capture text
being edited. Implementing ProcessDialogKey does not seem
to make any difference other than being called before
invoking KeyPress and KeyDown methods.

Any suggestions on how to capture Tabs, and up, down, left
and right arrows.

Thanks for your suggestions.

-----Original Message-----
Hi,

You will need to override the following methods in the DataGrid itself to
tap into keyboard navigation:

ProcessDialogKey - this method will be called when no cell is being edited
ProcessKeyPreview - this method will be called whe a cell IS being edited to
separate control keys strokes as Tab or Arrows from regular alpha-numeric
keystrokes that should be treated as user input.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Wild Goose said:
Hi all, Need some help here.

I have created my own DataGridTextBoxColumn and
DataGridTableStyle and have bound this to the DataGrid.
I am trying to capture the text changed event on a
DataGridTextBoxColumn. I need an event to be triggered
when the user either edit's text in the textbox, or tabs
on textbox, hits enter key, or presses up/down/right/left
keys.
I tried capturing the LostFocus & Leave events on the
DataGridTextBoxColumn. These events fires only if the
users hits tab on the column. It does not fire on hitting
enter key.
The TextChanged event fires for each character typed,
which probably I think I should be using to check for
integrity of data, but then how do I tell once the user
has finished typing.

Can anyone help me in this context.

Let me know if you still need more explanation.

Thanks

.
 
W

WildGooose

One other questions.

The ProcessKeyPreview event is fired each time I press
enter key on any columns in the Datagrid.
Is it possible to trigger the event only on a specific
column of the datagrid.

Thanks once again.

-----Original Message-----
Hi,

You will need to override the following methods in the DataGrid itself to
tap into keyboard navigation:

ProcessDialogKey - this method will be called when no cell is being edited
ProcessKeyPreview - this method will be called whe a cell IS being edited to
separate control keys strokes as Tab or Arrows from regular alpha-numeric
keystrokes that should be treated as user input.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Wild Goose said:
Hi all, Need some help here.

I have created my own DataGridTextBoxColumn and
DataGridTableStyle and have bound this to the DataGrid.
I am trying to capture the text changed event on a
DataGridTextBoxColumn. I need an event to be triggered
when the user either edit's text in the textbox, or tabs
on textbox, hits enter key, or presses up/down/right/left
keys.
I tried capturing the LostFocus & Leave events on the
DataGridTextBoxColumn. These events fires only if the
users hits tab on the column. It does not fire on hitting
enter key.
The TextChanged event fires for each character typed,
which probably I think I should be using to check for
integrity of data, but then how do I tell once the user
has finished typing.

Can anyone help me in this context.

Let me know if you still need more explanation.

Thanks

.
 
D

Dmitriy Lapshin [C# / .NET MVP]

I think I have a problem. I implemented ProcessKeyPreview,
and it seems to be capturing only 'Enter' key. Tab, and

In my case this method captured everything when the input focus was owned by
the text box inside a grid cell. That's actually the way the grid intercepts
arrow keys' strokes before they arrive the text box itself.

Just for clarity, I would like to stress that I'm speaking of
DataGrid.ProcessKeyPreview, not TextBox.ProcessKeyPreview.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

WildGooose said:
Dmitriy -

I think I have a problem. I implemented ProcessKeyPreview,
and it seems to be capturing only 'Enter' key. Tab, and
directional keys are not being captured. I have also
implemented KeyPress and KeyDown methods to capture text
being edited. Implementing ProcessDialogKey does not seem
to make any difference other than being called before
invoking KeyPress and KeyDown methods.

Any suggestions on how to capture Tabs, and up, down, left
and right arrows.

Thanks for your suggestions.

-----Original Message-----
Hi,

You will need to override the following methods in the DataGrid itself to
tap into keyboard navigation:

ProcessDialogKey - this method will be called when no cell is being edited
ProcessKeyPreview - this method will be called whe a cell IS being edited to
separate control keys strokes as Tab or Arrows from regular alpha-numeric
keystrokes that should be treated as user input.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Wild Goose said:
Hi all, Need some help here.

I have created my own DataGridTextBoxColumn and
DataGridTableStyle and have bound this to the DataGrid.
I am trying to capture the text changed event on a
DataGridTextBoxColumn. I need an event to be triggered
when the user either edit's text in the textbox, or tabs
on textbox, hits enter key, or presses up/down/right/left
keys.
I tried capturing the LostFocus & Leave events on the
DataGridTextBoxColumn. These events fires only if the
users hits tab on the column. It does not fire on hitting
enter key.
The TextChanged event fires for each character typed,
which probably I think I should be using to check for
integrity of data, but then how do I tell once the user
has finished typing.

Can anyone help me in this context.

Let me know if you still need more explanation.

Thanks

.
 
D

Dmitriy Lapshin [C# / .NET MVP]

You cannot disable triggering the event but you can always check current
column number by reading CurrentCell.ColumnNumber and not to react on the
event when it is fired on a column of no interest to you.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

WildGooose said:
One other questions.

The ProcessKeyPreview event is fired each time I press
enter key on any columns in the Datagrid.
Is it possible to trigger the event only on a specific
column of the datagrid.

Thanks once again.

-----Original Message-----
Hi,

You will need to override the following methods in the DataGrid itself to
tap into keyboard navigation:

ProcessDialogKey - this method will be called when no cell is being edited
ProcessKeyPreview - this method will be called whe a cell IS being edited to
separate control keys strokes as Tab or Arrows from regular alpha-numeric
keystrokes that should be treated as user input.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Wild Goose said:
Hi all, Need some help here.

I have created my own DataGridTextBoxColumn and
DataGridTableStyle and have bound this to the DataGrid.
I am trying to capture the text changed event on a
DataGridTextBoxColumn. I need an event to be triggered
when the user either edit's text in the textbox, or tabs
on textbox, hits enter key, or presses up/down/right/left
keys.
I tried capturing the LostFocus & Leave events on the
DataGridTextBoxColumn. These events fires only if the
users hits tab on the column. It does not fire on hitting
enter key.
The TextChanged event fires for each character typed,
which probably I think I should be using to check for
integrity of data, but then how do I tell once the user
has finished typing.

Can anyone help me in this context.

Let me know if you still need more explanation.

Thanks

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top