|
-
Feb 3rd, 2003, 03:14 PM
#1
Thread Starter
Hyperactive Member
Pass ListView as parameter
Sups
I have this decleration:
VB Code:
Public Sub ShowBoard(Key As String, List As ListView)
...
[B]If frmMain[COLOR=red].List[/COLOR].SelectedItem.Index <> 1 Then[/B]
...
End Sub
I have two ListView controls, and in the Click event, I want the two controls to performe the same action. I wrote 1 public sub as you can see, and i'm passing the ListView control as a parameter:
VB Code:
Private Sub List1_Click()
Call ShowBoard("Mouse", List1)
End Sub
The problem is that I get an Error that it cant recodnize the control: "Method or data member not found"
How can I resolve that?
-
Feb 3rd, 2003, 03:28 PM
#2
Since you pass the ListView control to your procedure then there is no reason to reference the form. Change your statement to
If List.SelectedItem.Index <> 1 Then
-
Feb 3rd, 2003, 03:35 PM
#3
Thread Starter
Hyperactive Member
-
Feb 3rd, 2003, 03:57 PM
#4
Thread Starter
Hyperactive Member
Is there a way to know which listview control is being used?
Seems like this dont work:
VB Code:
If List = frmMain.List2 Then
-
Feb 3rd, 2003, 04:10 PM
#5
If List is frmMain.List2 Then
-
Feb 3rd, 2003, 04:10 PM
#6
Frenzied Member
Code:
If List.Name="List2" then
...
-
Feb 3rd, 2003, 05:01 PM
#7
Thread Starter
Hyperactive Member
One more question:
I have a listview with 2 columns on it.
How do I get the text of an item in the second column?
God damnit...This control is too complicated for me
-
Feb 3rd, 2003, 05:11 PM
#8
Fanatic Member
item.subitems(1)
where item is a list item.
VB Code:
'second column
listview.selecteditem.subitems(1)
It Never Fails. Everytime I try to make a program idiot proof, the world makes a better idiot.
-
Feb 3rd, 2003, 05:20 PM
#9
The View style must be Report to get columns. Use the ListSubItem property.
VB Code:
Dim objItem As ListItem
With ListView1
.View = lvwReport
.ColumnHeaders.Add , , "Column 1"
.ColumnHeaders.Add , , "Column 2"
.ColumnHeaders.Add , , "Column 3"
Set objItem = .ListItems.Add(, , "Testing 1")
objItem.ListSubItems.Add , , "Sub Item 1"
objItem.ListSubItems.Add , , "Sub Item 2"
Set objItem = .ListItems.Add(, , "Testing 2")
objItem.ListSubItems.Add , , "Sub Item 1"
objItem.ListSubItems.Add , , "Sub Item 2"
End With
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
|