CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2010
    Posts
    14

    [RESOLVED] Need help displaying subitem text in listview control in Tile view

    I have been struggling with this for a while now and can't seem to get subitem text to appear in a listview control in tile view mode. I do have visual styles enabled. If anyone could take a look at my code and give me a hand with this i would be obliged! This code works fine for any other view, I am able to insert columns, items, and set subitem text no problem.

    Create the listview

    Code:
    DWORD style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | LVS_SHAREIMAGELISTS;
    DWORD exstyle = LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP;
    
    hwnd = CreateWindowEx(
          0, 
          WC_LISTVIEW, 
          NULL, 
          style, 
          CW_USEDEFAULT, 
          CW_USEDEFAULT, 
          CW_USEDEFAULT, 
          CW_USEDEFAULT,
          parent, 
          NULL, 
          GetModuleHandle(NULL), 
          NULL);
    
    SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, (LPARAM)exstyle);
    Set tile view

    Code:
    SendMessage(hwnd, LVM_SETVIEW, (WPARAM)LV_VIEW_TILE, 0);
    
    LVTILEVIEWINFO tvi = {0};
    tvi.cbSize = sizeof(LVTILEVIEWINFO);
    tvi.dwMask = LVTVIM_COLUMNS;
    tvi.cLines = 2; // 2 subitems
    
    SendMessage(hwnd, LVM_SETTILEVIEWINFO, 0, (LPARAM)&tvi);
    Insert items

    Code:
    // Uncommenting code works fine but still no subitem text appears
    
    // INT colfmt[2] = { LVCFMT_LEFT, LVCFMT_LEFT };
    // UINT order[2];
    
    LVITEM lvi = {0};
    lvi.mask = LVIF_TEXT | LVIF_IMAGE | (group >= 0? LVIF_GROUPID: 0) | LVIF_PARAM; // LVIF_COLUMNS | LVIF_COLFMT
    lvi.iItem = index;
    lvi.iImage = image;
    lvi.pszText = buffer;
    lvi.lParam = param;
    lvi.iGroupId = group;
    // lvi.cColumns = 2;
    // lvi.piColFmt = colfmt;
    // lvi.puColumns = order;
    
    INT ret = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM)&lvi);
    Add columns

    Code:
     // Commented code doesn't seem to have any effect
    
    LVCOLUMN lvc = {0};
    lvc.mask = LVCF_TEXT | (image >= 0? LVCF_IMAGE: 0) | LVCF_WIDTH; // LVCF_SUBITEM;
    lvc.pszText = buffer;
    lvc.cx = width;
    lvc.iImage = image;
    // lvc.iSubItem = subitem; 
    
    INT ret = SendMessage(hwnd, LVM_INSERTCOLUMN, (WPARAM)index, (LPARAM)&lvc);
    Set subitem text

    Code:
    LVITEM lvi = {0};
    lvi.mask = LVIF_TEXT;
    lvi.iItem = index;
    lvi.iSubItem = subitem; // <-- nothing happens whether I add columns first or not
    lvi.pszText = buffer;
    
    SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&lvi);

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Need help displaying subitem text in listview control in Tile view

    Victor Nijegorodov

  3. #3
    Join Date
    Dec 2010
    Posts
    14

    Re: Need help displaying subitem text in listview control in Tile view

    Thanks very much, that helped me solve this! I was using the puColumns member improperly when inserting items.
    Last edited by falcon60; July 23rd, 2015 at 09:37 AM.

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: [RESOLVED] Need help displaying subitem text in listview control in Tile view

    columns -> report view
    you're using tile view.

  5. #5
    Join Date
    Dec 2010
    Posts
    14

    Re: [RESOLVED] Need help displaying subitem text in listview control in Tile view

    Quote Originally Posted by OReubens View Post
    columns -> report view
    you're using tile view.
    If I don't insert columns it doesn't display subitems in tile view. Only in report view columns are actually visible.

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

Featured