|
-
October 27th, 2004, 01:27 PM
#1
Display results in Listview
Newbie. I have a menu with a checkbox (chkHamburger), a combobox for the quanity (cboHamburger). When I click the check box for Hamburger and select the Quanity, I would like for it to be displayed in the List View box. Below is the code I have written my my button click event.
Dim dblHamburger As Double
cboHamburger2.SelectedIndex = -1
If chkHamburger.Checked = True Then
Select Case cboHamburger2.SelectedIndex
Case 0
dblHamburger = 1.99
Case 1
dblHamburger = 2 * 1.99
Case 2
dblHamburger = 3 * 1.99
Case 4
dblHamburger = 4 * 1.99
Case 5
dblHamburger = 5 * 1.99
End Select
Else
dblHamburger = 0.0
End If
If I send this to a messagebox I get zero when i select any quanity:
MessageBox.Show(dblHamburger)
-
October 27th, 2004, 03:14 PM
#2
Re: Display results in Listview
You're getting zero because you're setting cboHamburger2.SelectedIndex = -1, so you Case Else is the one always executing. Moreoever, get rid of the case statement altogether!!
if cboHamburger2.SelectedIndex <> -1 then
dblHamburger = (cboHamburger2.SelectedIndex + 1) * 1.99
else
dblHambruger = 0
end if
Msgbox (cstr(cblHamburger))
-
October 28th, 2004, 10:59 AM
#3
Re: Display results in Listview
Cool got the msgbox to work with a little bit of tweaking. Now how would I incorporate the listviewbox (lstOrder) to show on one line the Quanity, Item (different hamburgers), and Price.
I have a listviewbox called lstOrder with those three columns: Quanity, Item, and Price.
-
October 28th, 2004, 04:03 PM
#4
Re: Display results in Listview
By "ListViewBox" do you mean ListBox or ListView? I would use a ListView personally. If that's what you mean, put one on your form and edit it's Style to "Detail" and edit it's Column property to add your columns. Then in your code where appropriate, add new ListItems as needed.
-
October 29th, 2004, 07:05 AM
#5
Re: Display results in Listview
DSJ,
that's clear, but how do you put each value into each column?
Listview1.Items(item_number).Text refers only to the first column, how do you get access to every single column?
Thanks
Did it help? rate it.
The best conversation I had was over forty million years ago ... and that was with a coffee machine.
-
October 29th, 2004, 08:03 AM
#6
Re: Display results in Listview
ListView.Items(idx).SubItems(colnum).Text = "Whatever"
-
October 29th, 2004, 08:17 AM
#7
Re: Display results in Listview
DSJ,
that's what I thought ... but I keep getting a System.ArgumentOutOfRangeException when I use colnum greater than 0, even if I can add subitems at design time 
To be precise, I can modify subitems created at design time, but how do I add a subitem at run-time?
Thanks
Last edited by DeepButi; October 29th, 2004 at 08:20 AM.
Did it help? rate it.
The best conversation I had was over forty million years ago ... and that was with a coffee machine.
-
October 29th, 2004, 08:23 AM
#8
Re: Display results in Listview
DSJ,
forget it ...
ListView1.Items(index).SubItems.Add(value)
Thanks
Did it help? rate it.
The best conversation I had was over forty million years ago ... and that was with a coffee machine.
-
October 29th, 2004, 09:51 AM
#9
Re: Display results in Listview
Dim i As Integer
Dim c As Integer
For c = 0 To 4
ListView2.Columns.Add(New ColumnHeader)
ListView2.Columns(c).Text = "Col" & c.ToString
Next
For i = 0 To 10
Dim li As New ListViewItem("Item " & i.ToString)
For c = 1 To 4
li.SubItems.Add("Col " & c.ToString)
Next
ListView2.Items.Add(li)
Next
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
|