Home All Groups Group Topic Archive Search About

Setting focus to a combobox in a grid

Author
24 Jul 2006 12:09 PM
mfleet1973@yahoo.ca
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.

Author
24 Jul 2006 1:12 PM
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

<mfleet1***@yahoo.ca> schreef in bericht
Show quoteHide quote
news:1153742983.911130.255530@p79g2000cwp.googlegroups.com...
> 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.
>
Author
24 Jul 2006 2:13 PM
mfleet1973@yahoo.ca
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.

Cor Ligthert [MVP] wrote:
Show quoteHide quote
> 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
>
> <mfleet1***@yahoo.ca> schreef in bericht
> news:1153742983.911130.255530@p79g2000cwp.googlegroups.com...
> > 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.
> >