Setting focus to a combobox in a grid

M

mfleet1973

Hello (again),

Within my datagrid I add a control to the datagridtextboxcolumn when
the underlying textbox receives focus as follows:

Combobox1.Size = New Size(Datagrid1.GetCurrentCellBounds().Width + 3,
combobox1.Size.Height)
sender.Controls.Add(Combobox1)

This works great. The problem is that when focus is set on the
combobox, and user presses the "down arrow" on the keyboard to scroll
to the next record, the combobox loses focus and focus is set behind
the combobox. I already have a BindingManagerBase to detect when user
scrolls to the next record. I try to set focus to the combobox in
there but without any success.

Is there a way to force focus to the combobox?

My thanks!

Mike.
 
C

Cor Ligthert [MVP]

Mike,

I have seen this behaviour to in a creation of a combobox. But the problem
is, you have to make your combobox for a datagrid yourself or to get it
somewhere from internet. Those can be wrong, investigating in that is not so
usefull anymore. The DataGridView has an inbuild combobox.

This are the some on our website

http://www.vb-tips.com/dbPages.aspx?ID=e51432cb-e517-4bae-bc26-7320e41e6d05

http://www.vb-tips.com/dbPages.aspx?ID=ca8d91a9-5aab-49fb-84a4-d5f9861ba534

http://www.vb-tips.com/dbPages.aspx?ID=af5ec1a9-bd98-4556-adf9-3866d4936de0

I hope this helps,

Cor
 
M

mfleet1973

Hi Cor.

I have done some research as well before sending the message this
morning but all the comboboxes I found on the internet work fine if the
combobox style is a dropdownlist but if the style is dropdown, there
are many little glitches. The combobox in the grid also has to
autocomplete the text (ie. when user presses a letter on the keyboard,
the text in the combobox automatically fills with the first item which
starts with the letter pressed).

I'll look at the links you have provided and let you know.

Thanks for all the help. You have saved me many hours of work.
 

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