Solved

VB.net/2005 Text/ComboBox combination

Posted on 2006-07-12
2
252 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:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Murray Brown
ID: 17089443
Thanks very much
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

630 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