Groups | Blog | Home
all groups > dotnet windows forms controls > may 2005 >

dotnet windows forms controls : DataGrid ComboBox and the New Row


Peter D. Dunlap
5/26/2005 10:19:24 AM
(Sounds like a Harry Potter title or something...)

After much searching and fiddling, I have finally got a working
DataGridComboBoxColumn and the associated DataGridComboBox control,
and they seem to work well, except for two odd things:

(1) If you are entering a value in the combo box on the new row, and
this causes another new row to be created, the first combo box event
disappears. If you open the dropdown and click a selection with the
mouse, the new row gets created and the combo box goes back to its
original selection. Same for if you hit a key to make the selection -
the first time creates the new row, and the next time you can actually
select something.

(2) The arrow keys do not work within the combo box to make
selections. The F4 key will open the selection list, but if you hit
the down arrow key it will move you to the next grid row and collapse
the select list.

Does anyone have a solution for either of these problems?

Pete Dunlap
Peter D. Dunlap
6/2/2005 10:30:30 PM
On Thu, 26 May 2005 10:19:24 -0400, Peter D. Dunlap
[quoted text, click to view]

More information on item (1) which is more important to figure out:

I go to the combo box on the new row and select an item. The
following things happen:

(a) In the ComboBox control, OnSelectionChangeCommitted happens, and
the selected index at that point is correct for the item I picked.

(b) The Edit function in the column style class is called.

(c) In the ComboBox control, OnSelectedIndexChanged happens, and the
selected index is now -1.

I'm not sure where to look to figure out what's happening. I've got
custom versions of the DataGrid, the column style and the ComboBox so
I can put debugging code anywhere in there, I just don't know where to
look next. (I've even got source for the system classes courtesy of
Reflector, but the DataGrid class in particular is huge...)
Peter D. Dunlap
6/3/2005 7:33:54 AM
On Thu, 02 Jun 2005 22:30:30 -0400, Peter D. Dunlap
[quoted text, click to view]

Ok, I've got problem (1) solved - I had to add a call to
SetColumnValueAtRow in the combo box's SelectionChangeCommitted event,
after saving the source and rowNum parameters in the Edit call.

However, (2), not being able to use the arrow keys to navigate the
dropdown list, is still a problem...
Peter D. Dunlap
6/6/2005 8:02:35 AM
On Fri, 03 Jun 2005 07:33:54 -0400, Peter D. Dunlap
[quoted text, click to view]

Ok, solved this problem too. I overrode ProcessKeyMessage in the
custom DataGridComboBox class, and for WM_KEYDOWN events for the up
and down arrow keys returned false without calling the base class.
Arun Raj.C
7/19/2005 12:31:06 PM
Hi Peter,

I also have the same Issue of not being able to use the arrow keys to
navigate the
dropdown list.

Can you please mail me the solution ? It would be a great help.

Thanks in Advance.
Arun Raj.C

[quoted text, click to view]
AddThis Social Bookmark Button