|
-
Mar 17th, 2005, 04:30 PM
#1
Thread Starter
Frenzied Member
Strange ComboBox Bug
I'm Every one
I've create a function That help me fill my combobox's, like this:
VB Code:
Public Sub FillComboBox(ByVal pCombo As System.Windows.Forms.ComboBox, ByVal pAccesBD As clsAccesDBSQL, ByVal pSQLQuery As String)
Dim dt As DataTable
dt = pAccesBD.GetDataSet(pSQLQuery).Tables(0)
pCombo.DataSource = dt
If dt.Rows.Count > 0 Then
pCombo.BeginUpdate()
pCombo.ValueMember = dt.Columns(0).ToString
pCombo.DisplayMember = dt.Columns(1).ToString
pCombo.EndUpdate()
End If
pCombo.SelectedIndex = -1
End Sub
My filled ComboBox, is on a TabControl on a Form, and when I switch to the second Tab and come back to the first tab, the First Item in my ComboBox is selected !?!? , I've absolutly no code "behind" that do so, and if I look to the SelectedIndex Before the tab switf it equal -1 after it's equal to 0 
Do somebody can help ...
-
Mar 17th, 2005, 09:11 PM
#2
Hyperactive Member
Re: Strange ComboBox Bug
dunno if this satisfies on what you seek, but as i observe about combobox the selected index value = 0 is the default, so you need to do some trapping about it, by adding this.
VB Code:
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
If Me.TabControl1.SelectedIndex = 0 Then
Me.ComboBox1.SelectedIndex = -1
End If
End Sub
or maybe there's another way that i dunno hehehe.
cheers.
-
Mar 18th, 2005, 08:05 AM
#3
Thread Starter
Frenzied Member
Re: Strange ComboBox Bug
Emmm it can be a solution, but it do not fix the bug ..
Last edited by Zakary; Mar 18th, 2005 at 08:13 AM.
Reason: Message Syntax error
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|