PC Review


Reply
Thread Tools Rate Thread

ComboBox first entry text is displayed,but SelectedIndex = -1

 
 
Scott M
Guest
Posts: n/a
 
      7th Aug 2003
I have combo boxes that use DataTables as the data source and while they
load just fine but the problem is that the text for the first entry in the
list is always displayed in every combo box (when it should be blank), even
though I set the SelectedIndex to -1. I cannot seem to find any way to stop
this. Any ideas?

Private Sub SetCustomersCombo()
m_Processing = True
' Sets the Data Table object associated with this Combo Box
With Me.cboSelectCustomer
.BeginUpdate()
.DataSource = m_DTCustomers
.DisplayMember = "Display"
.ValueMember = "ID"
.EndUpdate()
.SelectedIndex = -1
End With
m_Processing = False
End Sub

...snippet of code that loads the DataTable object

ItemIndex = 0
With m_DTCustomers
.Clear()
.Columns.Add(New DataColumn("ID", GetType(Integer)))
.Columns.Add(New DataColumn("Display", GetType(String)))
Do While MyDataReader.Read
.Rows.Add(.NewRow())
.Rows(ItemIndex)(0) = MyDataReader.GetInt32(0)
.Rows(ItemIndex)(1) = MyDataReader.GetString(1)
ItemIndex += 1
Loop
End With



 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      8th Aug 2003
Hello,

"Scott M" <(E-Mail Removed)> schrieb:
> I have combo boxes that use DataTables as the data
> source and while they load just fine but the problem is that the
> text for the first entry in the list is always displayed in every
> combo box (when it should be blank), even though I
> set the SelectedIndex to -1. I cannot seem to find any
> way to stop this. Any ideas?


BUG: ComboBox Does Not Clear When You Set SelectedIndex to -1
http://support.microsoft.com/?id=327244

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


 
Reply With Quote
 
Scott M
Guest
Posts: n/a
 
      8th Aug 2003
Thanks. FYI - the bug continues through Framework version 1.1.4322, not just
1.0.

"Herfried K. Wagner [MVP]" <(E-Mail Removed)> wrote in message
news:e2b%(E-Mail Removed)...
> Hello,
>
> "Scott M" <(E-Mail Removed)> schrieb:
> > I have combo boxes that use DataTables as the data
> > source and while they load just fine but the problem is that the
> > text for the first entry in the list is always displayed in every
> > combo box (when it should be blank), even though I
> > set the SelectedIndex to -1. I cannot seem to find any
> > way to stop this. Any ideas?

>
> BUG: ComboBox Does Not Clear When You Set SelectedIndex to -1
> http://support.microsoft.com/?id=327244
>
> HTH,
> Herfried K. Wagner
> --
> MVP · VB Classic, VB .NET
> http://www.mvps.org/dotnet
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get Displayed Text of a ComboBox David C. Holley Microsoft Access VBA Modules 2 3rd Jun 2010 10:45 AM
combobox.SelectedIndex = -1 does not empty combobox =?Utf-8?B?d2VzYmlyZA==?= Microsoft Dot NET Framework Forms 1 24th Mar 2006 02:56 PM
Cannot set SelectedIndex to -1 in ComboBox =?Utf-8?B?U3RldmUgRHl0ZQ==?= Microsoft VB .NET 10 21st Feb 2005 01:15 PM
ComboBox.SelectedIndex = -1 Ralf Ziller Microsoft Dot NET Compact Framework 2 18th Jan 2005 05:40 PM
ComboBox.SelectedIndex bug? Strahimir Antoljak Microsoft VB .NET 4 6th Jan 2004 06:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:44 AM.