Solved

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

Posted on 2012-03-23
5
251 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 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