In my last topic ( http://news.infragistics.com/forums/p/22571/83427.aspx#83427 )i managed to add a new row to my grid while tabbing in the last cell in the last row.
Now i want the same thing in another grid but the PreviewKeyDown won't fire for me. WIth some testing i found out that it would fire after being in a cell that has either a checkbox or a dropdownlist (that does not allow editing). I suspect that the problem lies in the fact that the last cell is just a regular cell that i'm editing at the time i'm trying to tab out of it. Do note that i can tab to the next cell just fine.
Anyone have any idea why the event doesn't fire and how i can get it to fire for my grid. I do need the PreviewKeyDown event btw because i want to know from which cell they are tabbing from.
Thanks in advance.
If the cell is using a masked editor, then there is no extra control. the editing is done right inside the grid. So the grid's MouseDown even will fire.
I'm trying to get ahold of the editor control that is painted above the active cell. I'm able to do this with normal textbox cells, but have been unable to get at the control for cells with Column.Style = ColumnStyle.IntegerNonNegative. I'm assuming that this has something to do with the mask nature of the control.
With the other cells, I've grabbed a handle on the active control by responding to the ControlAdded event.private void dataGrid_ControlAdded(object sender, ControlEventArgs e){ if (dataGrid.ActiveCell != null) e.Control.MouseDown += new MouseEventHandler(textControl_MouseDown);}
So far, whenever I enter a cell with a masked control, the ControlAdded event is never fired. I've looked through the FAQ article you referenced above, but have been unable to find a sample of this situation. Is there another way to accomplish this?
renzov said:But i have no idea how i can bind the PreviewKeyDown event to the TextBox control.
What you can do is handle the ControlAdded and ControlRemoved events of the grid. In ControlAdded, you can examine the control being added - it will most likely always be a TextBox control (or an EmbeddabledTextBoxWithUIPermissions, which is a derived TextBox). Then you can hook any events of the TextBox that you want in ControlAdded and unhook them in ControlRemoved.
This KB article does this for mouse events:
FAQ:Mouse events such as MouseDown, MouseUp, and DoubleClick do not fire when the mouse is over a cell that is in edit mode.
Thanks for your reply.
I'm sure its not firing at all. There are no checks or anything yet in the event. However i did bind the event to the grid itself. I expected myself already that the ActiveControl wasn't the grid while editing. But i have no idea how i can bind the PreviewKeyDown event to the TextBox control.
I'm not sure, but it probably has something to do with the fact that when a regular text cell goes into edit mode, the grid will display a TextBox control over the cell to allow editing. So the grid is not the ActivateControl at that point.
Are you sure PreviewKeyDown is not firing at all? Or is it firing, but skipping your code because you are checking for the ActiveControl being the grid?