Solved

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

Posted on 2012-03-23
5
249 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
You can also use SelectedIndex to 0 to select the first item in combobox.
0
 

Author Closing Comment

by:searchsanjaysharma
Comment Utility
ok
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

12 Experts available now in Live!

Get 1:1 Help Now