ListView with Multiple columns?

tuxp3
04-19-2004, 08:11 PM
curip(curnum).Text = curnum
curping(curnum).Text = "sljhf" ' random text to test with
curip(curnum).SubItems.Add(curping(curnum))
Dim Line As Integer
Line = listv.Items.Count
listv.Items.Insert(Line, curip(curnum))

listv is my listview
i try this but i get this error when i run the program

An unhandled exception of type 'System.NullReferenceException' occurred in PROJECT1.exe

Additional information: Object reference not set to an instance of an object.
and it highlights the first line,
any help on using multiple columns in ListView?

Thanks,
Andrew

okie20
04-21-2004, 09:37 AM
it looks to me like this line
curip(curnum).Text = curnum
is trying to get a value from curnum, which looks to be undeclared, giving you the null reference exception

tuxp3
04-21-2004, 11:37 AM
it looks to me like this line
curip(curnum).Text = curnum
is trying to get a value from curnum, which looks to be undeclared, giving you the null reference exception

well, that is just part of the code..

dim curip() as ItemView.Item
dim curping() as ItemView.SubItem
dim curnum as integer
for curnum =0 to 200 then
curip(curnum).Text = curnum
curping(curnum).Text = "sljhf" ' random text to test with
curip(curnum).SubItems.Add(curping(curnum))
Dim Line As Integer
Line = listv.Items.Count
listv.Items.Insert(Line, curip(curnum))
next


thats the whole.. so i did declare curnum and all the others

Andrew

okie20
04-21-2004, 01:22 PM
Im not sure if this is what you are looking for, but try using ListViewItem and ListViewItem.ListViewSubItem.

Also, I have a little snippet of code that MIGHT assist:

Dim myItem() As String
Dim item As New ListViewItem()

myItem(0) = string 'in this context
myItem(1) = string 'in this context

item = New ListViewItem(myItem)

listv.items.add(item)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum