Setting focus to a combobox in a grid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mfleet1973@yahoo.ca

    Setting focus to a combobox in a grid

    Hello (again),

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

    Combobox1.Size = New Size(Datagrid1. GetCurrentCellB ounds().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 BindingManagerB ase 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.

  • Cor Ligthert [MVP]

    #2
    Re: Setting focus to a combobox in a grid

    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







    I hope this helps,

    Cor

    <mfleet1973@yah oo.caschreef in bericht
    news:1153742983 .911130.255530@ p79g2000cwp.goo glegroups.com.. .
    Hello (again),
    >
    Within my datagrid I add a control to the datagridtextbox column when
    the underlying textbox receives focus as follows:
    >
    Combobox1.Size = New Size(Datagrid1. GetCurrentCellB ounds().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 BindingManagerB ase 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.
    >

    Comment

    • mfleet1973@yahoo.ca

      #3
      Re: Setting focus to a combobox in a grid

      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:
      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
      >

      >

      >

      >
      I hope this helps,
      >
      Cor
      >
      <mfleet1973@yah oo.caschreef in bericht
      news:1153742983 .911130.255530@ p79g2000cwp.goo glegroups.com.. .
      Hello (again),

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

      Combobox1.Size = New Size(Datagrid1. GetCurrentCellB ounds().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 BindingManagerB ase 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.

      Comment

      Working...