VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

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




Combo Box setting

 

Combo Box setting

kueh82

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
+Quote Post


dineeshd

RE: Combo Box Setting

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


Group Icon

Joined: 30 Jun, 2008
Posts: 618



Thanked: 30 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
+Quote Post

kueh82

RE: Combo Box Setting

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
+Quote Post

dineeshd

RE: Combo Box Setting

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


Group Icon

Joined: 30 Jun, 2008
Posts: 618



Thanked: 30 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
+Quote Post

kueh82

RE: Combo Box Setting

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
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 04:20AM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month