Results 1 to 6 of 6

Thread: cannot add items to second column in ListView

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Question cannot add items to second column in ListView

    My List View is set to Report style.
    I can add data to the first column fine, but when I try to use the iSubItem flag, the string is not added to the second column.

    Code:
    lvColumn.mask = LVCF_TEXT | LVCF_WIDTH;
    lvColumn.cx = 100;
    lvColumn.pszText = "Column 1";
    ListView_InsertColumn(hWndListView, 0, &lvColumn);
    
    lvColumn.pszText = "Column 2";
    ListView_InsertColumn(hWndListView, 1, &lvColumn);
    
    lvItem.mask = LVIF_TEXT;
    lvItem.pszText = "row 1, col 1";
    ListView_InsertItem(hWndListView, &lvItem);
    
    lvItem.pszText = "row 2, col 1";
    ListView_InsertItem(hWndListView, &lvItem);
    
    lvItem.iSubItem = 1;
    lvItem.pszText = "row 1, col 2";
    ListView_InsertItem(hWndListView, &lvItem);

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Col header or data?
    For Data you use:

    ListView_SetItemText(g_hWnd_ListView, iCol, iSubItes, LPSTR_String)
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  3. #3
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    So for:
    lvItem.pszText = "row 2, col 1";
    ListView_InsertItem(hWndListView, &lvItem);

    ListView_SetItemText(g_hWnd_ListView, 1, 1 /*Remember starts with 0*/,"row 2, col 1")

    If you need any more help get my Demo of the progressbar in a listview

    http://www.vbforums.com/showthread.p...hreadid=185111
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    Thank you.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    Can you autosize the column widths or do you have to set them manually?

    And can you disable the manual mouse resizing of the columns?

  6. #6
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Can you autosize the column widths or do you have to set them manually?
    I dont know the answer, but I will look it up. I think you have to do it manually.

    And can you disable the manual mouse resizing of the columns?
    Look at my demo, under WM_NOTIFY, you will see there how I keep the size from going below 80. Just take out the 80 part and have it return TRUE;

    Sorry I dont have to program infront of me, I am at home, or I would just give you the code.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width