Simulate Click-Event in ComboBox

Discussion in 'Microsoft VB .NET' started by DraguVaso, Mar 29, 2004.

  1. DraguVaso

    DraguVaso Guest

    Hi,

    I'm having a DataGrid with a Combobox bound to it. When I enter a
    DataGridCell the comboBox is shown. BUT, to typ something in it or scroll
    through the ComoBox-Items I have to click a second time in it.

    Now my queqtion is: how can I kind of 'simulate' the Click in that ComboBox,
    so that, on the moment the users enters the cell (by MouseClick or Tab-Key),
    the second clikc is done automatically?

    Anybody got any idea?

    Thanks!

    Pieter
     
    DraguVaso, Mar 29, 2004
    #1
    1. Advertisements

  2. DraguVaso

    yEah rIgHt Guest

    call this: ComboBox1_Click(sender, New System.EventArgs())



    DraguVaso wrote:
    > Hi,
    >
    > I'm having a DataGrid with a Combobox bound to it. When I enter a
    > DataGridCell the comboBox is shown. BUT, to typ something in it or scroll
    > through the ComoBox-Items I have to click a second time in it.
    >
    > Now my queqtion is: how can I kind of 'simulate' the Click in that ComboBox,
    > so that, on the moment the users enters the cell (by MouseClick or Tab-Key),
    > the second clikc is done automatically?
    >
    > Anybody got any idea?
    >
    > Thanks!
    >
    > Pieter
    >
    >
     
    yEah rIgHt, Mar 29, 2004
    #2
    1. Advertisements

  3. DraguVaso

    DraguVaso Guest

    It's not calling the function that I need, but really simulating the Click:
    The ComboBox doesn't get the right focus until the user clicks on it. Waht I
    need is that I can give it automaticly the focus. The method ComboBox.Focus
    doesn't work: The CombobBox gets the focus, but it's still not the same like
    when the user clicks in it :-/

    "yEah rIgHt" <> wrote in message
    news:...
    >
    > call this: ComboBox1_Click(sender, New System.EventArgs())
    >
    >
    >
    > DraguVaso wrote:
    > > Hi,
    > >
    > > I'm having a DataGrid with a Combobox bound to it. When I enter a
    > > DataGridCell the comboBox is shown. BUT, to typ something in it or

    scroll
    > > through the ComoBox-Items I have to click a second time in it.
    > >
    > > Now my queqtion is: how can I kind of 'simulate' the Click in that

    ComboBox,
    > > so that, on the moment the users enters the cell (by MouseClick or

    Tab-Key),
    > > the second clikc is done automatically?
    > >
    > > Anybody got any idea?
    > >
    > > Thanks!
    > >
    > > Pieter
    > >
    > >
     
    DraguVaso, Mar 30, 2004
    #3
  4. DraguVaso

    DraguVaso Guest

    Well, I wasn't really correct:
    when I use the ComboBox.Focus: the ComboBox disappears and the underlying
    GridCell is visible and gets the Focus.... really weird in my opinion...
    Maybe there is something there that worked bad...?

    This is the code I used:
    Dim cb As New System.Drawing.Rectangle 'cell bounds
    cboGrid.DataSource = Nothing
    cboGrid.Text = Nothing

    Dim strText As String
    strText = dbgMulti.Item(dbgMulti.CurrentRowIndex, intColumn)

    cb = dbgMulti.GetCellBounds(dbgMulti.CurrentRowIndex,
    intColumn)
    cboGrid.Location = New Point(cb.X, cb.Y)
    cboGrid.Size = New Size(cb.Width, cb.Height)
    cboGrid.BringToFront()
    cboGrid.Tag = "Open"
    cboGrid.Show()

    Try
    'opvullen
    cboGrid.DataSource = dtsMulti.Tables("tblTitles")
    cboGrid.DisplayMember = "ContactTitle"
    'oorspronkelijke waarde er inzetten
    cboGrid.Text = strText
    Catch

    End Try

    cboGrid.Focus()
    cboGrid.BringToFront()


    "DraguVaso" <> wrote in message
    news:...
    > It's not calling the function that I need, but really simulating the

    Click:
    > The ComboBox doesn't get the right focus until the user clicks on it. Waht

    I
    > need is that I can give it automaticly the focus. The method

    ComboBox.Focus
    > doesn't work: The CombobBox gets the focus, but it's still not the same

    like
    > when the user clicks in it :-/
    >
    > "yEah rIgHt" <> wrote in message
    > news:...
    > >
    > > call this: ComboBox1_Click(sender, New System.EventArgs())
    > >
    > >
    > >
    > > DraguVaso wrote:
    > > > Hi,
    > > >
    > > > I'm having a DataGrid with a Combobox bound to it. When I enter a
    > > > DataGridCell the comboBox is shown. BUT, to typ something in it or

    > scroll
    > > > through the ComoBox-Items I have to click a second time in it.
    > > >
    > > > Now my queqtion is: how can I kind of 'simulate' the Click in that

    > ComboBox,
    > > > so that, on the moment the users enters the cell (by MouseClick or

    > Tab-Key),
    > > > the second clikc is done automatically?
    > > >
    > > > Anybody got any idea?
    > > >
    > > > Thanks!
    > > >
    > > > Pieter
    > > >
    > > >

    >
    >
     
    DraguVaso, Mar 30, 2004
    #4
  5. DraguVaso

    DraguVaso Guest

    AAAAAargh, I just found it myself! I was able to give the ComboBox the Focus
    by setting the DataGridCell.enabled = false!

    Hehehe happy I found it :)

    "DraguVaso" <> wrote in message
    news:...
    > Well, I wasn't really correct:
    > when I use the ComboBox.Focus: the ComboBox disappears and the underlying
    > GridCell is visible and gets the Focus.... really weird in my opinion...
    > Maybe there is something there that worked bad...?
    >
    > This is the code I used:
    > Dim cb As New System.Drawing.Rectangle 'cell bounds
    > cboGrid.DataSource = Nothing
    > cboGrid.Text = Nothing
    >
    > Dim strText As String
    > strText = dbgMulti.Item(dbgMulti.CurrentRowIndex,

    intColumn)
    >
    > cb = dbgMulti.GetCellBounds(dbgMulti.CurrentRowIndex,
    > intColumn)
    > cboGrid.Location = New Point(cb.X, cb.Y)
    > cboGrid.Size = New Size(cb.Width, cb.Height)
    > cboGrid.BringToFront()
    > cboGrid.Tag = "Open"
    > cboGrid.Show()
    >
    > Try
    > 'opvullen
    > cboGrid.DataSource = dtsMulti.Tables("tblTitles")
    > cboGrid.DisplayMember = "ContactTitle"
    > 'oorspronkelijke waarde er inzetten
    > cboGrid.Text = strText
    > Catch
    >
    > End Try
    >
    > cboGrid.Focus()
    > cboGrid.BringToFront()
    >
    >
    > "DraguVaso" <> wrote in message
    > news:...
    > > It's not calling the function that I need, but really simulating the

    > Click:
    > > The ComboBox doesn't get the right focus until the user clicks on it.

    Waht
    > I
    > > need is that I can give it automaticly the focus. The method

    > ComboBox.Focus
    > > doesn't work: The CombobBox gets the focus, but it's still not the same

    > like
    > > when the user clicks in it :-/
    > >
    > > "yEah rIgHt" <> wrote in message
    > > news:...
    > > >
    > > > call this: ComboBox1_Click(sender, New System.EventArgs())
    > > >
    > > >
    > > >
    > > > DraguVaso wrote:
    > > > > Hi,
    > > > >
    > > > > I'm having a DataGrid with a Combobox bound to it. When I enter a
    > > > > DataGridCell the comboBox is shown. BUT, to typ something in it or

    > > scroll
    > > > > through the ComoBox-Items I have to click a second time in it.
    > > > >
    > > > > Now my queqtion is: how can I kind of 'simulate' the Click in that

    > > ComboBox,
    > > > > so that, on the moment the users enters the cell (by MouseClick or

    > > Tab-Key),
    > > > > the second clikc is done automatically?
    > > > >
    > > > > Anybody got any idea?
    > > > >
    > > > > Thanks!
    > > > >
    > > > > Pieter
    > > > >
    > > > >

    > >
    > >

    >
    >
     
    DraguVaso, Mar 30, 2004
    #5
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. trevor

    combobox click event not fired

    trevor, Oct 21, 2003, in forum: Microsoft VB .NET
    Replies:
    1
    Views:
    260
    Herfried K. Wagner [MVP]
    Oct 21, 2003
  2. Maileen

    simulate an event

    Maileen, Aug 8, 2005, in forum: Microsoft VB .NET
    Replies:
    3
    Views:
    163
    Herfried K. Wagner [MVP]
    Aug 9, 2005
  3. Hardik Shah

    Right click event on ComboBox

    Hardik Shah, Dec 20, 2005, in forum: Microsoft VB .NET
    Replies:
    2
    Views:
    395
    Hardik Shah
    Dec 21, 2005
  4. Glenn Palomar

    How to simulate mouse click in vb.net

    Glenn Palomar, May 6, 2006, in forum: Microsoft VB .NET
    Replies:
    3
    Views:
    5,603
    Herfried K. Wagner [MVP]
    May 8, 2006
  5. Replies:
    1
    Views:
    310
    Andrew Morton
    Dec 6, 2006
Loading...

Share This Page