ComboBox DroppedDown questions

P

Paul

VB.NET 2003. I am loading a dialog box form with a ComboBox. I'm
using a DropDownStyle of "DropDown" rather than "DropDownList". I
want them to be able to type in it fill in as they type. The ComboBox
contains a list of cities. The form will receive a parameter of one
alpha-numeric character.

I want to do two things (that I don't know how to do):

1. The parameter received to be moved to the ComboBox and the cursor
to be positioned
at the end of the character. So they can continue to type and
have the city filled in.
I can get the ComboBox.Text to be the value of the parameter.
But the field is selected.
I cannot get it unselected. So they have the type the character
a second time.

2. The list box part of the ComboBox dropped down. I can get it to
drop down. But the
list box part then goes back up. I'm guessing it is because the
form is loading. I've tried
putting the code in the Form Activated event, but that didn't
help.

Any suggestions?
 
C

ClayB

Try this code.

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.ComboBox1.DroppedDown = True
Me.ComboBox1.Text = ""
Me.ComboBox1.Focus()
SendKeys.Send("S") 'set an S into the combobox
End Sub

=================
Clay Burch
Syncfusion, Inc.
 
P

Paul

Thanks Clay. I had thought of that too, but wanted to avoid it. I
don't like using the SendKeys command. You can never really know how
the keys are going to be sent. But it did work and I'm going with it
for now.
 

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