ComboBox Question

dwilliams
01-30-2004, 07:21 AM
I have a combobox that I can add items to, but the items *never* are displayed at runtime ... In the below code, I have tried getting logical drive letters into the combobox directly - nothing displays in combobox although debug shows 5 items (which is correct - I have 5 logical drives). I have tried getting the list of logical drives into a string and adding the string with AddRange but still no items show in the combobox. I can look at the contents of the string (str) and I see the 5 logical drives as 5 text items but still nothing will show in the combobox ... seems the only way to get anything to show in the combobox is to hard code them through the properties window for combobox items collection (not desired).

Any clue why the combobox will never show anything??

Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Combobox1 As New ComboBox
Dim str() As String
str = IO.Directory.GetLogicalDrives
Combobox1.Items.AddRange(str)
'Combobox1.Items.AddRange(IO.Directory.GetLogicalDrives)
End Sub

Csharp
01-30-2004, 07:27 AM
if you are using " Dim Combobox1 As New ComboBox " you will never see anything , you need to either make that combobox visible on your form , or use an existing combobox that you already have. eg:

Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'/// assuming you have a Combobox1 on your form...
Combobox1.Items.AddRange(IO.Directory.GetLogicalDrives)
End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum