-
Feb 20th, 2010, 11:12 PM
#1
Thread Starter
Addicted Member
[RESOLVED] How to move to next line in listview
. How do I proceed to the next line in list view? my code is
Code:
Dim LVItem As New ListViewItem
Dim total(29) As Decimal
Dim q As Integer
If q <= 29 Then
LVItem.Text = PFlavor(q)
If Quantity(q) = 1 Then
LVItem.SubItems.Add("".ToString)
LVItem.SubItems.Add("".ToString)
Else
LVItem.SubItems.Add(price(q).ToString)
LVItem.SubItems.Add(Quantity(q).ToString)
End If
total(q) = price(q) * Quantity(q)
LVItem.SubItems.Add(total(q).ToString)
ListView1.Items.Add(LVItem)
q += 1
End If
q = 0
-
Feb 20th, 2010, 11:22 PM
#2
Re: How to move to next line in listview
vb Code:
Dim total(29) As Decimal
for q as integer = 0 to 29
Dim LVItem As New ListViewItem
LVItem.Text = PFlavor(q)
If Quantity(q) = 1 Then
LVItem.SubItems.Add("")
LVItem.SubItems.Add("")
Else
LVItem.SubItems.Add(price(q).ToString)
LVItem.SubItems.Add(Quantity(q).ToString)
End If
total(q) = price(q) * Quantity(q)
LVItem.SubItems.Add(total(q).ToString)
ListView1.Items.Add(LVItem)
next
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 20th, 2010, 11:30 PM
#3
Thread Starter
Addicted Member
Re: How to move to next line in listview
It seems that the program loops infinitly
-
Feb 20th, 2010, 11:34 PM
#4
Re: How to move to next line in listview
can you post the exact code you're using?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 20th, 2010, 11:36 PM
#5
Thread Starter
Addicted Member
Re: How to move to next line in listview
My bad. it's ok now. Uhm.. How do you prevent the program from displaying empty arrays? Say if (4) and so on is empty.
-
Feb 20th, 2010, 11:44 PM
#6
Re: How to move to next line in listview
vb Code:
Dim total(29) As Decimal
for q as integer = 0 to 29
if PFlavor(q) <> "" then
Dim LVItem As New ListViewItem
LVItem.Text = PFlavor(q)
If Quantity(q) = 1 Then
LVItem.SubItems.Add("")
LVItem.SubItems.Add("")
Else
LVItem.SubItems.Add(price(q).ToString)
LVItem.SubItems.Add(Quantity(q).ToString)
End If
total(q) = price(q) * Quantity(q)
LVItem.SubItems.Add(total(q).ToString)
ListView1.Items.Add(LVItem)
end if
next
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 21st, 2010, 12:02 AM
#7
Thread Starter
Addicted Member
Re: How to move to next line in listview
Thanks. it works now. i've got another question. I want to update the listview from another form. So far, i can only write 1 line. if I try to enter a new line, and error pops up saying i can't over write the line. Also, the line breaks at the 2nd column. May I know which code breaks the line?
Code:
Dim total(29) As Decimal
Quantity(c) = txtQuantity.Text
frmMainS.ListView1.Items.Add(PFlavor(c))
If Quantity(c) <> 0 Then
If Quantity(c) = 1 Then
Dim LVItem As New ListViewItem
frmMainS.LVItem.SubItems.Add("")
frmMainS.LVItem.SubItems.Add("")
Else
frmMainS.LVItem.SubItems.Add(price(c).ToString)
frmMainS.LVItem.SubItems.Add(Quantity(c).ToString)
End If
total(c) = price(c) * Quantity(c)
frmMainS.LVItem.SubItems.Add(total(c).ToString)
frmMainS.ListView1.Items.Add(frmMainS.LVItem)
c += 1
End If
-
Feb 21st, 2010, 12:04 AM
#8
Re: How to move to next line in listview
frmMainS.LVItem should be just LVItem
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 21st, 2010, 12:07 AM
#9
Thread Starter
Addicted Member
Re: How to move to next line in listview
Thanks. but the line still breaks at the 2nd column. The subitems are written on the following line
-
Feb 21st, 2010, 12:31 AM
#10
Hyperactive Member
Re: How to move to next line in listview
Last edited by yogesh12; Feb 21st, 2010 at 12:48 AM.
-
Feb 21st, 2010, 12:41 AM
#11
Re: How to move to next line in listview
remove this:
vb Code:
frmMainS.ListView1.Items.Add(PFlavor(c))
+ change this:
Dim LVItem As New ListViewItem(PFlavor(c))
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 21st, 2010, 12:48 AM
#12
Re: How to move to next line in listview
the lvItem declaration should be before:
+ not inside the if block
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 21st, 2010, 12:49 AM
#13
Thread Starter
Addicted Member
Re: How to move to next line in listview
yep. thanks! work's fine now.
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
|