Solved

VB.net/2005 Text/ComboBox combination

Posted on 2006-07-12
2
213 Views
Last Modified: 2010-04-23
Hi

I wanted to know if you could use a ComboBox like a text box too.
I want my ComboBox to have have four items to choose from, but also alow the user to
type in anything else.
Is this possible?
0
Comment
Question by:murbro
2 Comments
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 500 total points
ID: 17089275
Yes its possible, make sure that the ComboBox's DropDownStyle property is set to DropDown (default anyway). Then you could handle the KeyPress event of the combobox like this:

Private Sub ComboBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress

        If e.KeyChar = ChrW(Keys.Enter) Then

            If Me.ComboBox1.Text <> String.Empty AndAlso Not Me.ComboBox1.Items.Contains(Me.ComboBox1.Text) Then

                Me.ComboBox1.Items.Add(Me.ComboBox1.Text)
                Me.ComboBox1.Text = String.Empty
            End If
        End If
    End Sub

---
where ComboBox1 is the name of your combobox
0
 

Author Comment

by:murbro
ID: 17089443
Thanks very much
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now