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. C / C++ / MFC
  4. Multicolumn listbox

Multicolumn listbox

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
12 Posts 2 Posters 0 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.
  • D danag

    I have a requirement to fill the listbox with 2 columns. I know how to implement a listbox with single column? Could someone tell me how to do it? Thanks

    C Offline
    C Offline
    Chris Losinger
    wrote on last edited by
    #2

    use a CListCtrl instead. -c


    Greenspun's Tenth Rule of Programming: "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."

    D 1 Reply Last reply
    0
    • C Chris Losinger

      use a CListCtrl instead. -c


      Greenspun's Tenth Rule of Programming: "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."

      D Offline
      D Offline
      danag
      wrote on last edited by
      #3

      Thanks for a quick response. I will try listcontrol.

      D 1 Reply Last reply
      0
      • D danag

        Thanks for a quick response. I will try listcontrol.

        D Offline
        D Offline
        danag
        wrote on last edited by
        #4

        I am getting an assertion failure in the last line of this function. When I click the 'Ignore' button, I am getting a message box with the message 'Unsupported operation was attempted'. I donot have any clue to fix it? Pl help me. BOOL displaydlg::OnInitDialog() { CListCtrl *plistb = (CListCtrl *) GetDlgItem(IDC_LIST2); LV_ITEM lvI; // Initialize LV_ITEM members that are common to all items lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; lvI.state = 0; lvI.stateMask = 0; lvI.iImage = 0; CString str; int i =0; if (m_pSet1->IsOpen()) { m_pSet1->Close(); } m_pSet1->Open(); while (!m_pSet1->IsEOF()) { lvI.iItem =i; lvI.iSubItem = 0; str = m_pSet1->m_Type; lvI.pszText = (LPSTR)LPCTSTR(str); lvI.cchTextMax = MAX_ITEMLEN; lvI.lParam = (LPARAM) i; if (plistb->InsertItem(&lvI) == -1) AfxMessageBox(_T("ListSelectData::FillListCtrl error"), MB_OK); i++; m_pSet1->MoveNext(); } return CDialog::OnInitDialog(); }

        C 2 Replies Last reply
        0
        • D danag

          I am getting an assertion failure in the last line of this function. When I click the 'Ignore' button, I am getting a message box with the message 'Unsupported operation was attempted'. I donot have any clue to fix it? Pl help me. BOOL displaydlg::OnInitDialog() { CListCtrl *plistb = (CListCtrl *) GetDlgItem(IDC_LIST2); LV_ITEM lvI; // Initialize LV_ITEM members that are common to all items lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; lvI.state = 0; lvI.stateMask = 0; lvI.iImage = 0; CString str; int i =0; if (m_pSet1->IsOpen()) { m_pSet1->Close(); } m_pSet1->Open(); while (!m_pSet1->IsEOF()) { lvI.iItem =i; lvI.iSubItem = 0; str = m_pSet1->m_Type; lvI.pszText = (LPSTR)LPCTSTR(str); lvI.cchTextMax = MAX_ITEMLEN; lvI.lParam = (LPARAM) i; if (plistb->InsertItem(&lvI) == -1) AfxMessageBox(_T("ListSelectData::FillListCtrl error"), MB_OK); i++; m_pSet1->MoveNext(); } return CDialog::OnInitDialog(); }

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #5

          are there any records in the recordset? -c


          Greenspun's Tenth Rule of Programming: "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."

          D 1 Reply Last reply
          0
          • C Chris Losinger

            are there any records in the recordset? -c


            Greenspun's Tenth Rule of Programming: "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."

            D Offline
            D Offline
            danag
            wrote on last edited by
            #6

            Yes, having 3 records. If i comment out return CDialog::OnInitialUpdate() and return TRUE, then I am not getting this assertion failure. Only after the dailog with the listctrl filled with the records, the assertion failure appears.

            1 Reply Last reply
            0
            • D danag

              I am getting an assertion failure in the last line of this function. When I click the 'Ignore' button, I am getting a message box with the message 'Unsupported operation was attempted'. I donot have any clue to fix it? Pl help me. BOOL displaydlg::OnInitDialog() { CListCtrl *plistb = (CListCtrl *) GetDlgItem(IDC_LIST2); LV_ITEM lvI; // Initialize LV_ITEM members that are common to all items lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; lvI.state = 0; lvI.stateMask = 0; lvI.iImage = 0; CString str; int i =0; if (m_pSet1->IsOpen()) { m_pSet1->Close(); } m_pSet1->Open(); while (!m_pSet1->IsEOF()) { lvI.iItem =i; lvI.iSubItem = 0; str = m_pSet1->m_Type; lvI.pszText = (LPSTR)LPCTSTR(str); lvI.cchTextMax = MAX_ITEMLEN; lvI.lParam = (LPARAM) i; if (plistb->InsertItem(&lvI) == -1) AfxMessageBox(_T("ListSelectData::FillListCtrl error"), MB_OK); i++; m_pSet1->MoveNext(); } return CDialog::OnInitDialog(); }

              C Offline
              C Offline
              Chris Losinger
              wrote on last edited by
              #7

              try this: call CDialog::OnInitDialog first in your function (not last). then return FALSE. -c


              Greenspun's Tenth Rule of Programming: "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."

              D 1 Reply Last reply
              0
              • C Chris Losinger

                try this: call CDialog::OnInitDialog first in your function (not last). then return FALSE. -c


                Greenspun's Tenth Rule of Programming: "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."

                D Offline
                D Offline
                danag
                wrote on last edited by
                #8

                No, it doesnot work.

                C 1 Reply Last reply
                0
                • D danag

                  No, it doesnot work.

                  C Offline
                  C Offline
                  Chris Losinger
                  wrote on last edited by
                  #9

                  what happens?


                  Greenspun's Tenth Rule of Programming: "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."

                  D 1 Reply Last reply
                  0
                  • C Chris Losinger

                    what happens?


                    Greenspun's Tenth Rule of Programming: "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."

                    D Offline
                    D Offline
                    danag
                    wrote on last edited by
                    #10

                    Getting an assertion failure immediately. If I click 'Ignore' button, an message box appears with msg 'unsupported operation was attempted'

                    C 1 Reply Last reply
                    0
                    • D danag

                      Getting an assertion failure immediately. If I click 'Ignore' button, an message box appears with msg 'unsupported operation was attempted'

                      C Offline
                      C Offline
                      Chris Losinger
                      wrote on last edited by
                      #11

                      can you step into the function?


                      Greenspun's Tenth Rule of Programming: "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."

                      D 1 Reply Last reply
                      0
                      • C Chris Losinger

                        can you step into the function?


                        Greenspun's Tenth Rule of Programming: "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."

                        D Offline
                        D Offline
                        danag
                        wrote on last edited by
                        #12

                        I fixed the problem. The assertion failure is thrown when calling DoDataExchange(); CDialog::OnInitialUpdate() calling CDialog::UpdateData(FALSE) calling CDialog::DoDataExchange(..). Actually I had an button control in the dialog and an corresponding button variable in the Dialog class and hence the DoDataExchange() had an line containing button variable. Then I removed the Button variable from the resource. But didnot remove from the code. I tried to remove the button variable from the Dialogs class and DoDataExchange() and thus it worked. Thanks for your help. Sorry for the trouble.

                        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