Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. How to Add String in MultiColumn ListBox

How to Add String in MultiColumn ListBox

Scheduled Pinned Locked Moved ATL / WTL / STL
c++tutorial
6 Posts 3 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pankaj Jain
    wrote on last edited by
    #1

    Hi All I m working on a ATL Project. I have to add string in a multi column List box using SendDlgItemMessage() but I dont get any idea about that. I m using it like this SendDlgItemMessage(IDC_LIST1, LB_INSERTSTRING, (WPARAM) 0, (LPARAM)"Hi"); SendDlgItemMessage(IDC_LIST1, LB_INSERTSTRING, (WPARAM) 1, (LPARAM)"All"); But it is not working. I want to Add "Hi" in one column and "All" other. If u have any Idea Please suggest me Thanks & Regards Pankaj Jain

    P S 2 Replies Last reply
    0
    • P Pankaj Jain

      Hi All I m working on a ATL Project. I have to add string in a multi column List box using SendDlgItemMessage() but I dont get any idea about that. I m using it like this SendDlgItemMessage(IDC_LIST1, LB_INSERTSTRING, (WPARAM) 0, (LPARAM)"Hi"); SendDlgItemMessage(IDC_LIST1, LB_INSERTSTRING, (WPARAM) 1, (LPARAM)"All"); But it is not working. I want to Add "Hi" in one column and "All" other. If u have any Idea Please suggest me Thanks & Regards Pankaj Jain

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      PK Jain wrote:

      But it is not working.

      What is exact problem ?

      PK Jain wrote:

      I want to Add "Hi" in one column and "All" other.

      WPARAM value refers to item index, not column index.

      Prasad Notifier using ATL | Operator new[],delete[][^]

      P 1 Reply Last reply
      0
      • P prasad_som

        PK Jain wrote:

        But it is not working.

        What is exact problem ?

        PK Jain wrote:

        I want to Add "Hi" in one column and "All" other.

        WPARAM value refers to item index, not column index.

        Prasad Notifier using ATL | Operator new[],delete[][^]

        P Offline
        P Offline
        Pankaj Jain
        wrote on last edited by
        #3

        Thanks, But my query is not solved How to Add String in MultiColumn ListBox using SendDlgItemMessage

        Pankaj Jain

        P 1 Reply Last reply
        0
        • P Pankaj Jain

          Thanks, But my query is not solved How to Add String in MultiColumn ListBox using SendDlgItemMessage

          Pankaj Jain

          P Offline
          P Offline
          prasad_som
          wrote on last edited by
          #4

          PK Jain wrote:

          But my query is not solved

          For that you need to answer questions asked. I asked, what do you mean by not working ?

          PK Jain wrote:

          How to Add String in MultiColumn ListBox using SendDlgItemMessage

          Same as you written in in your original post. I think you mistaken multicolumn with number of columns as in list box. In case of list box, multi column means, there will be no vertical scrolling as number of string keeps increasing. Instead, string will be added to next column and so on, and horizontal scroll bar will appear. I hope this clear your doubts.

          Prasad Notifier using ATL | Operator new[],delete[][^]

          P 1 Reply Last reply
          0
          • P Pankaj Jain

            Hi All I m working on a ATL Project. I have to add string in a multi column List box using SendDlgItemMessage() but I dont get any idea about that. I m using it like this SendDlgItemMessage(IDC_LIST1, LB_INSERTSTRING, (WPARAM) 0, (LPARAM)"Hi"); SendDlgItemMessage(IDC_LIST1, LB_INSERTSTRING, (WPARAM) 1, (LPARAM)"All"); But it is not working. I want to Add "Hi" in one column and "All" other. If u have any Idea Please suggest me Thanks & Regards Pankaj Jain

            S Offline
            S Offline
            Stuart Dootson
            wrote on last edited by
            #5

            A MultiColumn ListBox doesn't give that functionality - you want a ListView instead. To add text to a ListView in the way you want, use something like:

            // Set up the columns
            LVCOLUMN col = {0};
            SendDlgItemMessage(IDC_LIST2, LVM_INSERTCOLUMN, 0, (LPARAM)&col);
            col.iSubItem = 1;
            SendDlgItemMessage(IDC_LIST2, LVM_INSERTCOLUMN, 1, (LPARAM)&col);
            
            LVITEM item = {0};
            item.mask = LVIF_TEXT;
            item.iSubItem = 0;
            item.pszText = "Hi";
            int itemIndex = (int)SendDlgItemMessage(IDC_LIST2, LVM_INSERTITEM, 0, (LPARAM)&item);
            item.iSubItem = 1;
            item.pszText = "All";
            SendDlgItemMessage(IDC_LIST2, LVM_SETITEMTEXT, itemIndex, (LPARAM)&item);
            
            SendDlgItemMessage(IDC_LIST2, LVM_SETCOLUMNWIDTH, 0, LVSCW_AUTOSIZE);
            SendDlgItemMessage(IDC_LIST2, LVM_SETCOLUMNWIDTH, 1, LVSCW_AUTOSIZE);
            

            [Updated to correct code, add column sizing]

            Last modified: 17mins after originally posted --

            1 Reply Last reply
            0
            • P prasad_som

              PK Jain wrote:

              But my query is not solved

              For that you need to answer questions asked. I asked, what do you mean by not working ?

              PK Jain wrote:

              How to Add String in MultiColumn ListBox using SendDlgItemMessage

              Same as you written in in your original post. I think you mistaken multicolumn with number of columns as in list box. In case of list box, multi column means, there will be no vertical scrolling as number of string keeps increasing. Instead, string will be added to next column and so on, and horizontal scroll bar will appear. I hope this clear your doubts.

              Prasad Notifier using ATL | Operator new[],delete[][^]

              P Offline
              P Offline
              Pankaj Jain
              wrote on last edited by
              #6

              Thanks Prasad, Thanks to clear my doubts

              Pankaj Jain

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups