Solved

How to enable the combobox to be read only mode. It should not be editable.

Posted on 2012-03-23
5
250 Views
Last Modified: 2012-03-26
In VB.Net Windows programming,
I am using combobox. At the top or first item is --Select City--.
I need two things.
1.First how to make it non editable.
2.How to reset it to --Select City-- on click on reset button.
0
Comment
Question by:searchsanjaysharma
  • 2
  • 2
5 Comments
 
LVL 17

Expert Comment

by:nepaluz
ID: 37756563
1. Set the DropDownStyle to list,e.g
        Dim xc As New ComboBox
        xc.DropDownStyle = ComboBoxStyle.DropDownList

Open in new window

2. Add this to your Rest Button click event
xc.SelectedValue = "--Select City--"

Open in new window

0
 

Author Comment

by:searchsanjaysharma
ID: 37764478
cmblastqualification.SelectedValue = "--Select Last Qualification"
            cmbcourse.SelectedValue = "--Select Course--"

This code is not working, here cmblastqualification and cmbcourse are the combboxes.
0
 
LVL 17

Accepted Solution

by:
nepaluz earned 250 total points
ID: 37764507
You need to add those values before you can set them i.e
cmbcourse.Items.Add("--Select Course--")
'then
cmbcourse.SelectedValue = "--Select Course--"

Open in new window

PS. Do NOT add the item in the click event, add it inthe form load
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 250 total points
ID: 37765131
You can also use SelectedIndex to 0 to select the first item in combobox.
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 37767021
ok
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
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 …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

919 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

21 Experts available now in Live!

Get 1:1 Help Now