Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filling Combobox 1

Status
Not open for further replies.

WelshyWizard

IS-IT--Management
Apr 23, 2006
89
GB
Hi all,

I have a combobox on a form that the user must make a selection from. It must not be left blank.

I fill the combobox list with the following code and also blank the text.

Code:
SqlDataAdapter4.Fill(DsCat11)
ComboBox2.DataSource = DsCat11.Category1
ComboBox2.DisplayMember = "Cat1"
ComboBox2.Text = ""

When the user hits the save button, I check if the ComboBox2.Text = "". If it does the user is notified that they must fill in the combobox. However, this is not working and when I actually check the ComoboBox2.text value it is taking the 1st value in the list.

What am I doing wrong? Is there a better way to go about this?

Cheers.

Today is the tomorrow you worried about yesterday - and all is well.....
 
Try this:

Instead of

ComboBox2.Text = ""

use

ComboBox2.SelectedIndex = -1



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top