Simulate Click-Event in ComboBox

D

DraguVaso

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
 
D

DraguVaso

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

DraguVaso

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()
 
D

DraguVaso

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 :)
 
Joined
Apr 3, 2015
Messages
1
Reaction score
0
Yeah Right - Thanks SO much for that reply- That NEW EventArgs is what I have been looking for - FINALLY...
 

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