Mar 6th, 2006, 04:57 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] ListView box hell
Hello,
I have been trying to get this to work for a long time and it has started to get on my nerves on more than one occasion.
Everyone knows how use a listbox, when you add an item i.e
VB Code:
Private Sub Command1_Click()
List1.AddItem Text1.Text
Text1.Text = ""
End Sub
This will add a text boxes text to the list box over again. So you will have more than 1 item in the list box.
How do i do this with a ListView box. i have included the form file below. I need to add 3 items from 3 text boxes into 3 coloumns.
Please Help
Jenova
Attached Files
Mar 6th, 2006, 06:09 PM
#2
Frenzied Member
Re: ListView box hell
Remove all columns what you set on custom mode.
You can do them by code
I did leave for next statements for sample view.
VB Code:
Private Sub Form_Load()
Dim i As Integer
With ListView1
.ColumnHeaders.Add(, , "Id").Tag = "Id"
.ColumnHeaders.Add(, , "Text1").Tag = "Text1"
.ColumnHeaders.Add(, , "Text2").Tag = "Text2"
.ColumnHeaders.Add(, , "Text3").Tag = "Text3"
.ColumnHeaders(1).Width = 0
.ColumnHeaders(2).Width = 2000
.ColumnHeaders(3).Width = 2000
.ColumnHeaders(4).Width = 2000
.ColumnHeaders(2).Alignment = lvwColumnLeft
.ColumnHeaders(3).Alignment = lvwColumnCenter
.ColumnHeaders(4).Alignment = lvwColumnRight
.SortKey = 2
.Sorted = True
.BorderStyle = ccFixedSingle
.View = lvwReport
End With
Text1 = "Sampletext 1"
Text2 = "Sampletext 2"
Text3 = "Sampletext 3"
ListView1.ListItems.Clear
With ListView1
With .ListItems
For i = 1 To 1
With .Add(, , CStr(i))
.ListSubItems.Add , , Text1
.ListSubItems.Add , , Text2
.ListSubItems.Add , , Text3
End With
Next
End With
End With
End Sub
oh1mie/Vic
Mar 6th, 2006, 06:20 PM
#3
Re: ListView box hell
The ListView contains a collection called ListItems. Use it to add new ListItem objects to the listview. A ListItem is the data for Column 1 in Report View.
The ListItem contains a collection called ListSubItems. Use it to add new ListSubItem objects to the ListItem. A ListSubItem is the data for the other columns.
You can also use the ListItem.SubItems array
VB Code:
Dim oNewItem As ListItem
Set oNewItem = ListView1.ListItems.Add(, , Text1.Text)
oNewItem.ListSubItems.Add , , Text2.Text
oNewItem.ListSubItems.Add , , Text3.Text
'or
oNewItem.SubItems(1) = Text2.Text
oNewItem.SubItems(2) = Text3.Text
Mar 6th, 2006, 06:49 PM
#4
Thread Starter
Hyperactive Member
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