By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,376 Members | 1,540 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,376 IT Pros & Developers. It's quick & easy.

ListBox, ComboBox Bug???

P: n/a
I am trying to dynamically add items to a listbox or combobox. The
items add to either, but when I look through those items, there is
nothing there. If I choose an item, it shows up.

Not sure why, but the items are not visible in the listbox or combobox
until one of the items has been chosen. This of course is not good,
since someone can not see the items they need to choose from.

Any help would be appreciated.

Scott Moore

Sep 13 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
What's the code you're using to populate them?

Thanks,

Seth Rowe

samoore33 wrote:
I am trying to dynamically add items to a listbox or combobox. The
items add to either, but when I look through those items, there is
nothing there. If I choose an item, it shows up.

Not sure why, but the items are not visible in the listbox or combobox
until one of the items has been chosen. This of course is not good,
since someone can not see the items they need to choose from.

Any help would be appreciated.

Scott Moore
Sep 13 '06 #2

P: n/a
Duh, brainfart! I acquired this PC from a previous programmer, he had
not updated to 1.1 Framework, could that be the problem. The form I am
working with may have been written on the 2.0 Framework.

myDataSet.ReadXML("this.xml")

The dataset has three tables in it. I use the foundRows DataRow to get
the id to match up the items in the third table.

'Used to searchthrough the dataset
Dim t As DataTable
t = myDataSet.Tables("State")
Dim strExpr = "id = '" &
returnItems.SubItems.Item(count).Text & "'"
Dim foundRows() As DataRow
'returns the datarows that were found in the search
foundRows = t.Select(strExpr)

Dim taxRow() As DataRow 'creates the tax row to be looped through to
populate the combobox

'Searches through the tax tabel of the dataset
taxRow = myDataSet.Tables("Tax").Select("Taxes_Id =
'" & foundRows(0)(2) & "'")

'Populates the combo box for updating purposes
If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 2 To 2
'I only need the second row out of the
datarow

cmbTest.Items.Add((taxRow(count)(k)).ToString())
Next
Next
End If


rowe_newsgroups wrote:
What's the code you're using to populate them?

Thanks,

Seth Rowe

samoore33 wrote:
I am trying to dynamically add items to a listbox or combobox. The
items add to either, but when I look through those items, there is
nothing there. If I choose an item, it shows up.

Not sure why, but the items are not visible in the listbox or combobox
until one of the items has been chosen. This of course is not good,
since someone can not see the items they need to choose from.

Any help would be appreciated.

Scott Moore
Sep 13 '06 #3

P: n/a
Well, nothing I see would make the combobox's contents "invisible."
Does a certain event fire this code? If you could, please post that
code too (everything from sub to end sub), I have a feeling you might
be calling this code in the wrong event. Also your below code shouldn't
need the inner for next loop - so you could change this:
If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 2 To 2
'I only need the second row out of the datarow
cmbTest.Items.Add((taxRow(count)(k)).ToString())
Next
Next
End If
to this:

If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
'I only need the second row out of the datarow
cmbTest.Items.Add((taxRow(count)(2)).ToString())
Next
End If

Thanks,

Seth Rowe
samoore33 wrote:
Duh, brainfart! I acquired this PC from a previous programmer, he had
not updated to 1.1 Framework, could that be the problem. The form I am
working with may have been written on the 2.0 Framework.

myDataSet.ReadXML("this.xml")

The dataset has three tables in it. I use the foundRows DataRow to get
the id to match up the items in the third table.

'Used to searchthrough the dataset
Dim t As DataTable
t = myDataSet.Tables("State")
Dim strExpr = "id = '" &
returnItems.SubItems.Item(count).Text & "'"
Dim foundRows() As DataRow
'returns the datarows that were found in the search
foundRows = t.Select(strExpr)

Dim taxRow() As DataRow 'creates the tax row to be looped through to
populate the combobox

'Searches through the tax tabel of the dataset
taxRow = myDataSet.Tables("Tax").Select("Taxes_Id =
'" & foundRows(0)(2) & "'")

'Populates the combo box for updating purposes
If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 2 To 2
'I only need the second row out of the
datarow

cmbTest.Items.Add((taxRow(count)(k)).ToString())
Next
Next
End If


rowe_newsgroups wrote:
What's the code you're using to populate them?

Thanks,

Seth Rowe

samoore33 wrote:
I am trying to dynamically add items to a listbox or combobox. The
items add to either, but when I look through those items, there is
nothing there. If I choose an item, it shows up.
>
Not sure why, but the items are not visible in the listbox or combobox
until one of the items has been chosen. This of course is not good,
since someone can not see the items they need to choose from.
>
Any help would be appreciated.
>
Scott Moore
Sep 13 '06 #4

P: n/a
The event that calls this is when the user selects an item out of the
listview. Code is below:

Private Sub lsvTest_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lsvTest.SelectedIndexChanged

'Clears the items in the combbo box
cmbTest.Items.Clear()

Dim TaxData As CRTTaxDataSet = New CRTTaxDataSet

'Reads the xml into the dataset
myDataSet.ReadXml("this.xml")

'dim variables to be used
Dim returnItems As ListViewItem =
Me.GetSelectedListViewItem(lsvTest.Items)
Dim item As String
Dim count As Integer

'loops through the item that has been selected to populate the
text boxes
For count = 0 To returnItems.SubItems.Count - 1
Select Case count
'Populates the corresponding textbox and old value
textbox for comparison for updating
Case 1
cboState.SelectedItem =
returnItems.SubItems.Item(count).Text

'Used to searchthrough the dataset
Dim t As DataTable
t = myDataSet.Tables("State")
Dim strExpr = "id = '" &
returnItems.SubItems.Item(count).Text & "'"
Dim foundRows() As DataRow
'returns the datarows that were found in the search
foundRows = t.Select(strExpr)

Dim taxRow() As DataRow 'creates the tax row to be
looped through to populate the combobox

'Searches through the tax tabel of the dataset
taxRow = myDataSet.Tables("Tax").Select("Taxes_Id =
'" & foundRows(0)(2) & "'", "Value")

'Populates the combo box for updating purposes
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 0 To 2
If k = 2 Then

cmbTest.Items.Add((taxRow(cnt)(k)).ToString())
End If
Next
Next
End Select
Next

'Clears the dataset
myDataSet.Clear()

End Sub

rowe_newsgroups wrote:
Well, nothing I see would make the combobox's contents "invisible."
Does a certain event fire this code? If you could, please post that
code too (everything from sub to end sub), I have a feeling you might
be calling this code in the wrong event. Also your below code shouldn't
need the inner for next loop - so you could change this:
If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 2 To 2
'I only need the second row out of the datarow
cmbTest.Items.Add((taxRow(count)(k)).ToString())
Next
Next
End If

to this:

If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
'I only need the second row out of the datarow
cmbTest.Items.Add((taxRow(count)(2)).ToString())
Next
End If

Thanks,

Seth Rowe
samoore33 wrote:
Duh, brainfart! I acquired this PC from a previous programmer, he had
not updated to 1.1 Framework, could that be the problem. The form I am
working with may have been written on the 2.0 Framework.

myDataSet.ReadXML("this.xml")

The dataset has three tables in it. I use the foundRows DataRow to get
the id to match up the items in the third table.

'Used to searchthrough the dataset
Dim t As DataTable
t = myDataSet.Tables("State")
Dim strExpr = "id = '" &
returnItems.SubItems.Item(count).Text & "'"
Dim foundRows() As DataRow
'returns the datarows that were found in the search
foundRows = t.Select(strExpr)

Dim taxRow() As DataRow 'creates the tax row to be looped through to
populate the combobox

'Searches through the tax tabel of the dataset
taxRow = myDataSet.Tables("Tax").Select("Taxes_Id =
'" & foundRows(0)(2) & "'")

'Populates the combo box for updating purposes
If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 2 To 2
'I only need the second row out of the
datarow

cmbTest.Items.Add((taxRow(count)(k)).ToString())
Next
Next
End If


rowe_newsgroups wrote:
What's the code you're using to populate them?
>
Thanks,
>
Seth Rowe
>
samoore33 wrote:
I am trying to dynamically add items to a listbox or combobox. The
items add to either, but when I look through those items, there is
nothing there. If I choose an item, it shows up.

Not sure why, but the items are not visible in the listbox or combobox
until one of the items has been chosen. This of course is not good,
since someone can not see the items they need to choose from.

Any help would be appreciated.

Scott Moore
Sep 15 '06 #5

P: n/a
Check that the drawmode property of the checkbox is set to "Normal".

"samoore33" wrote:
The event that calls this is when the user selects an item out of the
listview. Code is below:

Private Sub lsvTest_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lsvTest.SelectedIndexChanged

'Clears the items in the combbo box
cmbTest.Items.Clear()

Dim TaxData As CRTTaxDataSet = New CRTTaxDataSet

'Reads the xml into the dataset
myDataSet.ReadXml("this.xml")

'dim variables to be used
Dim returnItems As ListViewItem =
Me.GetSelectedListViewItem(lsvTest.Items)
Dim item As String
Dim count As Integer

'loops through the item that has been selected to populate the
text boxes
For count = 0 To returnItems.SubItems.Count - 1
Select Case count
'Populates the corresponding textbox and old value
textbox for comparison for updating
Case 1
cboState.SelectedItem =
returnItems.SubItems.Item(count).Text

'Used to searchthrough the dataset
Dim t As DataTable
t = myDataSet.Tables("State")
Dim strExpr = "id = '" &
returnItems.SubItems.Item(count).Text & "'"
Dim foundRows() As DataRow
'returns the datarows that were found in the search
foundRows = t.Select(strExpr)

Dim taxRow() As DataRow 'creates the tax row to be
looped through to populate the combobox

'Searches through the tax tabel of the dataset
taxRow = myDataSet.Tables("Tax").Select("Taxes_Id =
'" & foundRows(0)(2) & "'", "Value")

'Populates the combo box for updating purposes
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 0 To 2
If k = 2 Then

cmbTest.Items.Add((taxRow(cnt)(k)).ToString())
End If
Next
Next
End Select
Next

'Clears the dataset
myDataSet.Clear()

End Sub

rowe_newsgroups wrote:
Well, nothing I see would make the combobox's contents "invisible."
Does a certain event fire this code? If you could, please post that
code too (everything from sub to end sub), I have a feeling you might
be calling this code in the wrong event. Also your below code shouldn't
need the inner for next loop - so you could change this:
If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 2 To 2
'I only need the second row out of the datarow
cmbTest.Items.Add((taxRow(count)(k)).ToString())
Next
Next
End If
to this:

If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
'I only need the second row out of the datarow
cmbTest.Items.Add((taxRow(count)(2)).ToString())
Next
End If

Thanks,

Seth Rowe
samoore33 wrote:
Duh, brainfart! I acquired this PC from a previous programmer, he had
not updated to 1.1 Framework, could that be the problem. The form I am
working with may have been written on the 2.0 Framework.
>
myDataSet.ReadXML("this.xml")
>
The dataset has three tables in it. I use the foundRows DataRow to get
the id to match up the items in the third table.
>
'Used to searchthrough the dataset
Dim t As DataTable
t = myDataSet.Tables("State")
Dim strExpr = "id = '" &
returnItems.SubItems.Item(count).Text & "'"
Dim foundRows() As DataRow
'returns the datarows that were found in the search
foundRows = t.Select(strExpr)
>
Dim taxRow() As DataRow 'creates the tax row to be looped through to
populate the combobox
>
'Searches through the tax tabel of the dataset
taxRow = myDataSet.Tables("Tax").Select("Taxes_Id =
'" & foundRows(0)(2) & "'")
>
'Populates the combo box for updating purposes
If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 2 To 2
'I only need the second row out of the
datarow
>
cmbTest.Items.Add((taxRow(count)(k)).ToString())
Next
Next
End If
>
>
>
>
rowe_newsgroups wrote:
What's the code you're using to populate them?

Thanks,

Seth Rowe

samoore33 wrote:
I am trying to dynamically add items to a listbox or combobox. The
items add to either, but when I look through those items, there is
nothing there. If I choose an item, it shows up.
>
Not sure why, but the items are not visible in the listbox or combobox
until one of the items has been chosen. This of course is not good,
since someone can not see the items they need to choose from.
>
Any help would be appreciated.
>
Scott Moore

Sep 22 '06 #6

P: n/a
I would check to make sure the drawmode property of the combobox is set to
"Normal".

"samoore33" wrote:
The event that calls this is when the user selects an item out of the
listview. Code is below:

Private Sub lsvTest_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lsvTest.SelectedIndexChanged

'Clears the items in the combbo box
cmbTest.Items.Clear()

Dim TaxData As CRTTaxDataSet = New CRTTaxDataSet

'Reads the xml into the dataset
myDataSet.ReadXml("this.xml")

'dim variables to be used
Dim returnItems As ListViewItem =
Me.GetSelectedListViewItem(lsvTest.Items)
Dim item As String
Dim count As Integer

'loops through the item that has been selected to populate the
text boxes
For count = 0 To returnItems.SubItems.Count - 1
Select Case count
'Populates the corresponding textbox and old value
textbox for comparison for updating
Case 1
cboState.SelectedItem =
returnItems.SubItems.Item(count).Text

'Used to searchthrough the dataset
Dim t As DataTable
t = myDataSet.Tables("State")
Dim strExpr = "id = '" &
returnItems.SubItems.Item(count).Text & "'"
Dim foundRows() As DataRow
'returns the datarows that were found in the search
foundRows = t.Select(strExpr)

Dim taxRow() As DataRow 'creates the tax row to be
looped through to populate the combobox

'Searches through the tax tabel of the dataset
taxRow = myDataSet.Tables("Tax").Select("Taxes_Id =
'" & foundRows(0)(2) & "'", "Value")

'Populates the combo box for updating purposes
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 0 To 2
If k = 2 Then

cmbTest.Items.Add((taxRow(cnt)(k)).ToString())
End If
Next
Next
End Select
Next

'Clears the dataset
myDataSet.Clear()

End Sub

rowe_newsgroups wrote:
Well, nothing I see would make the combobox's contents "invisible."
Does a certain event fire this code? If you could, please post that
code too (everything from sub to end sub), I have a feeling you might
be calling this code in the wrong event. Also your below code shouldn't
need the inner for next loop - so you could change this:
If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 2 To 2
'I only need the second row out of the datarow
cmbTest.Items.Add((taxRow(count)(k)).ToString())
Next
Next
End If
to this:

If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
'I only need the second row out of the datarow
cmbTest.Items.Add((taxRow(count)(2)).ToString())
Next
End If

Thanks,

Seth Rowe
samoore33 wrote:
Duh, brainfart! I acquired this PC from a previous programmer, he had
not updated to 1.1 Framework, could that be the problem. The form I am
working with may have been written on the 2.0 Framework.
>
myDataSet.ReadXML("this.xml")
>
The dataset has three tables in it. I use the foundRows DataRow to get
the id to match up the items in the third table.
>
'Used to searchthrough the dataset
Dim t As DataTable
t = myDataSet.Tables("State")
Dim strExpr = "id = '" &
returnItems.SubItems.Item(count).Text & "'"
Dim foundRows() As DataRow
'returns the datarows that were found in the search
foundRows = t.Select(strExpr)
>
Dim taxRow() As DataRow 'creates the tax row to be looped through to
populate the combobox
>
'Searches through the tax tabel of the dataset
taxRow = myDataSet.Tables("Tax").Select("Taxes_Id =
'" & foundRows(0)(2) & "'")
>
'Populates the combo box for updating purposes
If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 2 To 2
'I only need the second row out of the
datarow
>
cmbTest.Items.Add((taxRow(count)(k)).ToString())
Next
Next
End If
>
>
>
>
rowe_newsgroups wrote:
What's the code you're using to populate them?

Thanks,

Seth Rowe

samoore33 wrote:
I am trying to dynamically add items to a listbox or combobox. The
items add to either, but when I look through those items, there is
nothing there. If I choose an item, it shows up.
>
Not sure why, but the items are not visible in the listbox or combobox
until one of the items has been chosen. This of course is not good,
since someone can not see the items they need to choose from.
>
Any help would be appreciated.
>
Scott Moore

Sep 22 '06 #7

P: n/a
Drawmod is set to Normal. I really think that it is a problem with the
..Net Framework. It works on other peoples computers, just not mine. I
appreciate the help.

Scott Moore

Easton wrote:
I would check to make sure the drawmode property of the combobox is set to
"Normal".

"samoore33" wrote:
The event that calls this is when the user selects an item out of the
listview. Code is below:

Private Sub lsvTest_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lsvTest.SelectedIndexChanged

'Clears the items in the combbo box
cmbTest.Items.Clear()

Dim TaxData As CRTTaxDataSet = New CRTTaxDataSet

'Reads the xml into the dataset
myDataSet.ReadXml("this.xml")

'dim variables to be used
Dim returnItems As ListViewItem =
Me.GetSelectedListViewItem(lsvTest.Items)
Dim item As String
Dim count As Integer

'loops through the item that has been selected to populate the
text boxes
For count = 0 To returnItems.SubItems.Count - 1
Select Case count
'Populates the corresponding textbox and old value
textbox for comparison for updating
Case 1
cboState.SelectedItem =
returnItems.SubItems.Item(count).Text

'Used to searchthrough the dataset
Dim t As DataTable
t = myDataSet.Tables("State")
Dim strExpr = "id = '" &
returnItems.SubItems.Item(count).Text & "'"
Dim foundRows() As DataRow
'returns the datarows that were found in the search
foundRows = t.Select(strExpr)

Dim taxRow() As DataRow 'creates the tax row to be
looped through to populate the combobox

'Searches through the tax tabel of the dataset
taxRow = myDataSet.Tables("Tax").Select("Taxes_Id =
'" & foundRows(0)(2) & "'", "Value")

'Populates the combo box for updating purposes
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 0 To 2
If k = 2 Then

cmbTest.Items.Add((taxRow(cnt)(k)).ToString())
End If
Next
Next
End Select
Next

'Clears the dataset
myDataSet.Clear()

End Sub

rowe_newsgroups wrote:
Well, nothing I see would make the combobox's contents "invisible."
Does a certain event fire this code? If you could, please post that
code too (everything from sub to end sub), I have a feeling you might
be calling this code in the wrong event. Also your below code shouldn't
need the inner for next loop - so you could change this:
>
If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 2 To 2
'I only need the second row out of the datarow
cmbTest.Items.Add((taxRow(count)(k)).ToString())
Next
Next
End If
>
to this:
>
If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
'I only need the second row out of the datarow
cmbTest.Items.Add((taxRow(count)(2)).ToString())
Next
End If
>
Thanks,
>
Seth Rowe
>
>
samoore33 wrote:
Duh, brainfart! I acquired this PC from a previous programmer, he had
not updated to 1.1 Framework, could that be the problem. The form I am
working with may have been written on the 2.0 Framework.

myDataSet.ReadXML("this.xml")

The dataset has three tables in it. I use the foundRows DataRow to get
the id to match up the items in the third table.

'Used to searchthrough the dataset
Dim t As DataTable
t = myDataSet.Tables("State")
Dim strExpr = "id = '" &
returnItems.SubItems.Item(count).Text & "'"
Dim foundRows() As DataRow
'returns the datarows that were found in the search
foundRows = t.Select(strExpr)

Dim taxRow() As DataRow 'creates the tax row to be looped through to
populate the combobox

'Searches through the tax tabel of the dataset
taxRow = myDataSet.Tables("Tax").Select("Taxes_Id =
'" & foundRows(0)(2) & "'")

'Populates the combo box for updating purposes
If taxRow.Length 1 Then
Dim cnt As Integer
For cnt = 0 To taxRow.Length - 1
Dim k As Integer
For k = 2 To 2
'I only need the second row out of the
datarow

cmbTest.Items.Add((taxRow(count)(k)).ToString())
Next
Next
End If




rowe_newsgroups wrote:
What's the code you're using to populate them?
>
Thanks,
>
Seth Rowe
>
samoore33 wrote:
I am trying to dynamically add items to a listbox or combobox. The
items add to either, but when I look through those items, there is
nothing there. If I choose an item, it shows up.

Not sure why, but the items are not visible in the listbox or combobox
until one of the items has been chosen. This of course is not good,
since someone can not see the items they need to choose from.

Any help would be appreciated.

Scott Moore
Sep 25 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.