For and next loop... problem
-
Hi, I am trying to insert selected items from a listbox into a label, the listbox is fillby a database query, the problem is all I get is this
System.Data.DataRowView
it works fine when I dont use a database query and just text in the listbox. Cant anyone help on a solution for this??Dim i As Integer For i = 0 To ListBoxUpgrade.Items.Count - 1 If ListBoxUpgrade.Items(i) Then LabelSum.Text = LabelSum.Text & Space(6) & ListBoxUpgrade.SelectedItem(i) & vbCrLf End If Next i
Thanks in advance! Stefan."All answers have a question? All code has an end."
-
Hi, I am trying to insert selected items from a listbox into a label, the listbox is fillby a database query, the problem is all I get is this
System.Data.DataRowView
it works fine when I dont use a database query and just text in the listbox. Cant anyone help on a solution for this??Dim i As Integer For i = 0 To ListBoxUpgrade.Items.Count - 1 If ListBoxUpgrade.Items(i) Then LabelSum.Text = LabelSum.Text & Space(6) & ListBoxUpgrade.SelectedItem(i) & vbCrLf End If Next i
Thanks in advance! Stefan."All answers have a question? All code has an end."
I don't use VB very much but from what I know in C# if you use something like ListBox1.SelectedItem[i] it would not work. ListBox1.SelectedItem[i] returns a ListItem this one has a Text and a Value property. I think you should use something like ListBoxUpgrade.SelectedItem(i).Text Hope it helps...
Just call me Valy... :)
-
Hi, I am trying to insert selected items from a listbox into a label, the listbox is fillby a database query, the problem is all I get is this
System.Data.DataRowView
it works fine when I dont use a database query and just text in the listbox. Cant anyone help on a solution for this??Dim i As Integer For i = 0 To ListBoxUpgrade.Items.Count - 1 If ListBoxUpgrade.Items(i) Then LabelSum.Text = LabelSum.Text & Space(6) & ListBoxUpgrade.SelectedItem(i) & vbCrLf End If Next i
Thanks in advance! Stefan."All answers have a question? All code has an end."
You must select a column index for the DataRowView. Try this:
for(int i=0; i<ListBoxUpgrade.Items.Count-1; i++) { if(ListBoxUpgrade.Items[i].IsSelected) { LabelSum.Text += " " + ((DataRowView)ListBoxUpgrade.SelectedItem[i])[yourIndex] + "\r\n"; } }
____________________________________ There is no proof for this sentence.
-
Hi, I am trying to insert selected items from a listbox into a label, the listbox is fillby a database query, the problem is all I get is this
System.Data.DataRowView
it works fine when I dont use a database query and just text in the listbox. Cant anyone help on a solution for this??Dim i As Integer For i = 0 To ListBoxUpgrade.Items.Count - 1 If ListBoxUpgrade.Items(i) Then LabelSum.Text = LabelSum.Text & Space(6) & ListBoxUpgrade.SelectedItem(i) & vbCrLf End If Next i
Thanks in advance! Stefan."All answers have a question? All code has an end."
-
no worries, if you browse long enough trhough CP you can tell the difference between people making a mistake and people just being lazy :-). There is no bad in making a mistake, it makes us human ;-).
V.
Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive