|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to add new rows to ListviewDear all,
I know that I can add text ListView like that Set Item = ListView1.ListItems.Add(, , "abc") Then I want to add another new row to the ListView, how can I do that? I have tried Set Item = ListView1.ListItems.Add(2, , "abc") But the "2" is only for column index but not row index. Please suggest me how to Add a new row in Listview. Thanks Use listview..AddItem("ABC")
defaults to add at end of list. -- Show quoteHide quoteIRFAN. "hon123456" wrote: > Dear all, > > I know that I can add text ListView like that Set Item = > ListView1.ListItems.Add(, , "abc") > Then I want to add another new row to the ListView, how can I do that? > I have tried > Set Item = ListView1.ListItems.Add(2, , "abc") But the "2" is only for > column index but not row > index. Please suggest me how to Add a new row in Listview. > > Thanks > hon123456 <peterhon***@yahoo.com.hk>'s wild thoughts were
released on Sun, 1 Mar 2009 20:27:18 -0800 (PST) bearing the following fruit: >Dear all, the "2" is the row index not the column index. You code> > I know that I can add text ListView like that Set Item = >ListView1.ListItems.Add(, , "abc") >Then I want to add another new row to the ListView, how can I do that? >I have tried >Set Item = ListView1.ListItems.Add(2, , "abc") But the "2" is only for >column index but not row >index. Please suggest me how to Add a new row in Listview. should work as is so I'm not sure what the problem is here. -- Jan Hyde https://mvp.support.microsoft.com/profile/Jan.Hyde thanks Jan,
But you can try to use the abouve code. You will find that it only add a new column but not a new row. Thanks hon123456 <peterhon***@yahoo.com.hk>'s wild thoughts were
released on Mon, 2 Mar 2009 20:09:04 -0800 (PST) bearing the following fruit: >thanks Jan, I did try your code. I suspect you don't have it in report> > But you can try to use the abouve code. You will find >that it only add >a new column but not a new row. mode. J >Thanks -- Jan Hyde https://mvp.support.microsoft.com/profile/Jan.Hyde "hon123456" <peterhon***@yahoo.com.hk> wrote in message The Index is the row index and specifes where to position the row being news:22d5eeee-c8ed-4fa3-88a3-cd7176f630ba@v5g2000prm.googlegroups.com... > Dear all, > > I know that I can add text ListView like that Set Item = > ListView1.ListItems.Add(, , "abc") > Then I want to add another new row to the ListView, how can I do that? > I have tried > Set Item = ListView1.ListItems.Add(2, , "abc") But the "2" is only for > column index but not row > index. Please suggest me how to Add a new row in Listview. added. Usually you just omit that and it adds the new row at the end. Running the code you posted results in two list items being added; if you are seeing it as two "columns" then my guess is that you didn't set the View property right and you're getting the Icon view which does look like 2 columns when you don't specify icons. Dim oItem As MSComctlLib.ListItem Dim oHdr As MSComctlLib.ColumnHeader Dim x As Long ListView1.View = lvwReport ListView1.FullRowSelect = True Set oHdr = ListView1.ColumnHeaders.Add(, , "Item Name") Set oHdr = ListView1.ColumnHeaders.Add(, , "Sub Item") Set oHdr = ListView1.ColumnHeaders.Add(, , "Second Sub") For x = 1 To 10 Set oItem = ListView1.ListItems.Add(, , "Item " & CStr(x)) oItem.SubItems(1) = "Sub 1-" & CStr(x) oItem.SubItems(2) = "Sub 2-" & CStr(x) Next Set oItem = ListView1.ListItems.Add(4, , "This one goes in the middle") If you don't have sub items for each row then you can also try using the List view: Dim oItem As MSComctlLib.ListItem Dim x As Long ListView1.View = lvwList Set oItem = ListView1.ListItems.Add(, , "Item 1") Set oItem = ListView1.ListItems.Add(, , "Item 2")
Please help to translate this short Delphi code
close excel from VB6 Pset and SetPixel Bug How to get special Appdata folder Use Proc with Static Variables Multiple Times What am I doing wrong How difficult is to add my menu to Windows Explorer? Unbelieveable code, it produces one result in VB6 run and another if compiled in a exe file ???? Wha Vista behaves differently to WordBasic command even though same version of Word! Legacy vs Opp |
|||||||||||||||||||||||