Solved

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.NET 2008 VB and C# 6 39
get combo value in class 5 14
VB.net Open video relating to control 2 20
VB.net Adding a row to a DataGridView that has a checkbox column 5 24
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 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