Solved

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

Posted on 2012-03-23
5
257 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
[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
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
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…

756 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