Datagrid ComboBox

M

Mike

I have a custom datagridcolumnstyle that hosts a combobox. If I tab into
this cell it skips over into the next cell. If I arrow into the cell, it
does not skip over.
This only happens when I attempt to set the focus on the combobox, as in the
following:

Protected Overloads Overrides Sub Edit(ByVal [source] As
CurrencyManager, ByVal rowNum As Integer, ByVal bounds As Rectangle, _
ByVal [readOnly] As Boolean, ByVal instantText As String, ByVal
cellIsVisible As Boolean)
Try
If cellIsVisible Then
MyComboBox.Bounds = New Rectangle(bounds.X + 2, bounds.Y +
2, bounds.Width - 4, bounds.Height - 4)
MyComboBox.Show()
MyComboBox.Focus()
Else
MyComboBox.Hide()
End If
Catch ex As Exception
Throw ex
End Try
End Sub

If I comment out the line MyComboBox.Focus() then tabbing into the cell does
not skip to the next cell. However, the combobox does not have the focus,
requiring the user to click into the combobox.

Does anyone know why this is happening?

Thanks,
Mike
 
R

Roger

I ran into this problem myself a while back. A solution that seemed to
work was to subclass the ComboBox and override the WndProc function so
that WM_KEYUP messages are ignored.

This is C# code rather than VB, but you get the idea:

const int WM_KEYUP = 0x101;
const int WM_KEYDOWN = 0x100;
protected override void WndProc(ref System.Windows.Forms.Message m)
{
if(m.Msg == WM_KEYUP)
{
//ignore keyup to avoid problem with tabbing & dropdownlist;
return;
}
base.WndProc(ref m);
}
 
M

Mike

Thanks for the suggestion. Unfortunately, I've already subclassed the
ComboBox to do just exactly what you suggested.
This problem happens when I tab into the DataGridComboBox from an adjacent
column. The ComboBox gets the focus for an instant and then focus goes to
the next adjacent column.
If I use the arrow keys, I don't have a problem. This only happens when I
tab.
 
M

Mike

I would have no problem purchasing if I didn't have a custom combobox
implemented in my datagridcombobox. Anyway, I traced problem to
dropdownstyles of simple and dropdown. Dropdownlist does not skip over to
next column.

Any ideas how to fix this?
 

Jee

Joined
Oct 3, 2006
Messages
1
Reaction score
0
I have this problem to and i have resolve it... it seem that an event occur after the edit event that make the combo lost is focus and then it execute the leave event of the combo then hide it... i have patch this by setting the focus on the combo box by enabling a timer that give focus then disable itself afterward.... i know that it is not really clean but it works lol
 

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