Results 1 to 7 of 7

Thread: Add multiple colums to a listview

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Add multiple colums to a listview

    Is there any example, code, tutorials that teaches you how to make multiple columns in a listview and then add the rows to it?

    Thanks if you provide me some link
    Baaaaaaaaah

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Would it be out of line to suggest MSDN?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    I already looked at msdn but it has the whole explorer application which is a little hard to understand. That is why I want just some code that can add even one row to a multicolumn listview
    Baaaaaaaaah

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    When you send the add item message, you can specify in the LV(_)ITEM structure what subitem to add it to.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5
    Megatron
    Guest
    Send LVM_INSERTCOLUMN to insert a column and LVM_INSERTITEM to insert an item.

  6. #6

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Originally posted by parksie
    When you send the add item message, you can specify in the LV(_)ITEM structure what subitem to add it to.
    But how do I use it? I am posting the function that I am using to create a listview with two columns and then I am trying to add two items to each column in a row. But it is actually adding the items to only the first column on two rows

    PHP Code:
    HWND CreateListView(HINSTANCE hinstanceHWND parenthwnd)
    {

        
    HWND lvhwnd;
        
    INITCOMMONCONTROLSEX icex;
        
    RECT rect;
        
    LVCOLUMN lvc;
        
    LVITEM lvi;

        
    GetClientRect(parenthwnd, &rect);

    // Ensure that the common control DLL is loaded. 
    icex.dwSize sizeof(INITCOMMONCONTROLSEX);
    icex.dwICC  ICC_LISTVIEW_CLASSES;
    //Initialize the commoncontrols library
        
    InitCommonControlsEx(&icex);

        
    //Create the listview control

        
    lvhwnd CreateWindowEx(WS_EX_CLIENTEDGE,
                                
    WC_LISTVIEW,
                                
    "",
                                
    WS_CHILD WS_VISIBLE LVS_REPORT LVS_EDITLABELS,
                                
    14,
                                
    65,
                                
    rect.right 106,
                                
    rect.bottom 155,
                                
    parenthwnd,
                                
    NULL,
                                
    hinstance,
                                
    NULL);

        
    GetClientRect(lvhwnd, &rect);

        
    //Add the columns the in the listview
        
    lvc.mask LVCF_WIDTH LVCF_TEXT;
        
    lvc.pszText "Macro";
        
    lvc.cx rect.right /3;

        
    ListView_InsertColumn(lvhwnd0, &lvc);

        
    lvc.mask LVCF_WIDTH LVCF_TEXT;
        
    lvc.pszText "Macro Definition";
        
    lvc.cx rect.right - (rect.right /3);

        
    ListView_InsertColumn(lvhwnd1, &lvc);
        
    //Add the item in the listview

        
    lvi.mask LVIF_TEXT |LVIF_PARAM LVIF_STATE;
        
    lvi.pszText "AAA";//LPSTR_TEXTCALLBACK; // sends an LVN_GETDISPINFO message.
        
    lvi.iItem 0;
        
    lvi.state 0;
        
    lvi.stateMask 0;
        
    lvi.iSubItem 0;

        
    ListView_InsertItem(lvhwnd, &lvi);

        
    lvi.mask LVIF_TEXT LVIF_PARAM LVIF_STATE;
        
    lvi.pszText "AAA";//LPSTR_TEXTCALLBACK; // sends an LVN_GETDISPINFO message.
        
    lvi.iItem 0;
        
    lvi.state 0;
        
    lvi.stateMask 0;
        
    lvi.iSubItem 0;

        
    ListView_InsertItem(lvhwnd, &lvi);

        return 
    lvhwnd;

    Baaaaaaaaah

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    lvi.iSubItem = 0;
    Play around with this value
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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