Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
i need help with displaying a number starting with 0 for each row thats created in the list view. Also when you select a row, that number i need it to show up as a pop up stating the row number. thanks in advanced for your help.


VB
Dim process = GetObject("winmgmts://./root/novadigm:NVD_Agent")
Dim method = process.Methods_("GetValue")
Dim inParameters = method.inParameters.SpawnInstance_()
inParameters.Path = strObject
Dim outParameters = process.ExecMethod_("NumberOfInstances", inParameters)
Dim StrHeaps = (outParameters.InstanceCount)
num_TextBox.Text = StrHeaps
For i = 0 To StrHeaps Step +1
    inParameters.Index = i

    inParameters.Property = "ZOBJNAME"
    outParameters = process.ExecMethod_("GetValue", inParameters)
    Dim Value1 As String = outParameters.Value

    inParameters.Property = "ZAVIS"
    outParameters = process.ExecMethod_("GetValue", inParameters)
    Dim Value2 As String = outParameters.Value

    inParameters.Property = "NAME"
    outParameters = process.ExecMethod_("GetValue", inParameters)
    Dim Value3 As String = outParameters.Value

    inParameters.Property = "#"
    outParameters = process.ExecMethod_("GetValue", inParameters)
    Dim Value4 As String = outParameters.Value

    Dim item1 As New ListViewItem(0)
    item1.SubItems.Add(Value1)
    item1.SubItems.Add(Value2)
    item1.SubItems.Add(Value3)
    ListView1.Items.Add(item1)
    ListView1.FullRowSelect = True


Next
Posted

The easiest way is to add a column to your data source that contains the row number.
 
Share this answer
 
Comments
Zachary.shupp 9-Feb-12 13:52pm    
i thought the same thing but the file that it puls from will change from time to time so i need something that will cover that.
Christian Graus 9-Feb-12 13:53pm    
You're building the listviewitem in code, so just track a number and insert it.
Zachary.shupp 9-Feb-12 14:14pm    
i dont understand what your saying. i know i m lisintg a few things but sometimes there can be 100 or is someone deletes something in the middle and i refresh it i want there to be no gaps in the numbers.
Christian Graus 9-Feb-12 14:19pm    
You get no gaps in the numbers, but you have to then reset the column when someone deletes a row. There's really no other way without writing a custom control that shows row numbers on it's own, without them coming from the data source.
Dim value4 = ListView1.Items.Count
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900