combobox.focus in a datagrid.

J

jereviscious

Hi all

I've added a combobox to the datagrid control using the following method

dataGridTextBoxColumn7.TextBox.Controls.Add(comboControl);



The problem is that when I tab to the Column that contains the combobox, the
focus is on the underlying textbox in the datagrid.

I've tried doing this:

comboControl.focus();

But unfortunately what happens here is that it forces a tab to the next
column! I can't get the comboControl to get the focus without clicking on it
with the mouse! very annoying. Any help would be appreciated.

MSDE 2003

..NET FRAMEWORK 1.1
 
J

jereviscious

Well I didn't have a lot of responses, so I've done some research over the
last couple of days, and here is what I've found. This would work great,
except for the fact that when you use ComboBoxStyle.DropDown, then the KeyUp
message isn't passed!!! (It does pass under ComboBoxStyle.DropDownList). So
I am still stuck after 2 days of work.

Any help would be greatly appreciated.

I sincerely hope that microsft makes this process easier in the future.
Ironically, doing these sorts of data entry screens was trivial in MS access
97! Have we regressed??!??
private const int WM_KEYUP = 0x101;

// The WndProc method corresponds exactly to the Windows WindowProc
function.

// For more information about processing Windows messages, see the
WindowProc

// function documentation in the Windows Platform SDK reference located in

// the MSDN Library.

protected override void WndProc(ref System.Windows.Forms.Message theMessage)

{

// Ignore KeyUp event to avoid problem with tabbing the dropdown.

if (theMessage.Msg == WM_KEYUP)

{

return;

}

else

{

base.WndProc(ref theMessage);

}

}


The Keyup event from the tab key is causing it to "skip" over the cell that
has the combobox, so several people use this method
 
J

jereviscious

Finally, the solution...
private const int WM_KEYUP = 0x101;

// The WndProc method corresponds exactly to the Windows WindowProc
function.

// For more information about processing Windows messages, see the
WindowProc

// function documentation in the Windows Platform SDK reference located in

// the MSDN Library.

public override bool PreProcessMessage(ref System.Windows.Forms.Message
theMessage)

{

// Ignore KeyUp event to avoid problem with tabbing the dropdown.

if (theMessage.Msg == WM_KEYUP)

{

return true;

}

else

{

base.WndProc(ref theMessage);

}

return false;
 

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