Solved

VB.net/2005 Text/ComboBox combination

Posted on 2006-07-12
2
228 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

770 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