Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 132,646 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,130 people online right now. Registration is fast and FREE... Join Now!




Combo Box setting

 
Reply to this topicStart new topic

Combo Box setting

kueh82
post 18 Aug, 2008 - 01:56 AM
Post #1


New D.I.C Head

*
Joined: 8 Aug, 2008
Posts: 9

i have 3 combo boxes in my form. During form load, i load the combo box, code as below:-

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

Load_PartGroup()
Load_StockCategory()
Load_Customer()

NewMode = True

Clear_Fields()

End Sub

Private Sub Clear_Fields()

ComboBox1.SelectedIndex = -1
cboCustomer.SelectedIndex = -1
cboCategory.SelectedIndex = -1

End If

what i want is, when the form load, load the combo box & set the combo box where selectedIndex=-1, so that the combo box can displayed blank combo box for me.

thank you.

This post has been edited by kueh82: 18 Aug, 2008 - 01:57 AM
User is offlineProfile CardPM

Go to the top of the page

dineeshd
post 18 Aug, 2008 - 02:09 AM
Post #2


D.I.C Addict

Group Icon
Joined: 30 Jun, 2008
Posts: 560



Thanked 16 times

Dream Kudos: 575
My Contributions


So what is the issue? ComboBox1.SelectedIndex = -1 will show the blank combobox, right? Or you want something else then explain.... rolleyes.gif

And Please use Code Tags while posting code.
Example: code.gif
User is offlineProfile CardPM

Go to the top of the page

kueh82
post 19 Aug, 2008 - 01:58 AM
Post #3


New D.I.C Head

*
Joined: 8 Aug, 2008
Posts: 9

QUOTE(dineeshd @ 18 Aug, 2008 - 03:09 AM) *

So what is the issue? ComboBox1.SelectedIndex = -1 will show the blank combobox, right? Or you want something else then explain.... rolleyes.gif

And Please use Code Tags while posting code.
Example: code.gif



Yes, you are correct. it is displayed blank combo box. the ComboBox1.SelectedIndex = -1 does not work if i put the code in form load. what i guess is because of my load function Load_PartGroup() which load data into the combobox1.....

at this moment, when my form is load, then all combo box displayed the default value. i want it show blank like (.SelectedIndex = -1) ......

thx
User is offlineProfile CardPM

Go to the top of the page

dineeshd
post 20 Aug, 2008 - 02:05 AM
Post #4


D.I.C Addict

Group Icon
Joined: 30 Jun, 2008
Posts: 560



Thanked 16 times

Dream Kudos: 575
My Contributions


Are you binding the data directly from database to combobox? If you can post the code of Load_PartGroup() function, there will be more clarity.
User is offlineProfile CardPM

Go to the top of the page

kueh82
post 20 Aug, 2008 - 02:38 AM
Post #5


New D.I.C Head

*
Joined: 8 Aug, 2008
Posts: 9

QUOTE(dineeshd @ 20 Aug, 2008 - 03:05 AM) *

Are you binding the data directly from database to combobox? If you can post the code of Load_PartGroup() function, there will be more clarity.


this is the code:-

Private Sub Load_PartGroup()

daPG = New SqlDataAdapter("Select * From nPartGroup Where Active = " & 1 & " ", sConn)
dsPG = New DataSet
daPG.Fill(dsPG, "nPartGroup")

With ComboBox1
.DataSource = dsPG.Tables(0)
.ValueMember = "PGID"
.DisplayMember = "PGName"
End With

End Sub
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 04:52AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month