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

    CListCtrl Question

    how do i insert an item into a list control?
    i use InsertItem(nItem, CString) to insert it but it doesnt work.
    this is the exact code i use:


    m_listCtrl.InsertItem(m_listCtrl.GetItemCount(), dlg.m_textQ);





    answers to why this wont help is appreciated.
    thanks,
    L5



  2. #2
    Join Date
    Apr 1999
    Posts
    19

    Re: CListCtrl Question

    Try this instead

    CListCtrl* pList = (CListCtrl*) GetDlgItem(IDC_YOUR_LIST_ID);
    pList->InsertItem(m_listCtrl.GetItemCount(), dlg.m_textQ);


  3. #3
    Join Date
    May 1999
    Posts
    17

    Re: CListCtrl Question

    I am afraid you should insert at least one column into the ListCtrl before you insert any items. So try put following line in your OnInitDialog function or OnInitialUpdate():
    m_listCtrl.InsertColumn(0, _T("ColumnHead Text"), LVCFMT_LEFT, 100, 0);


    For more information about InsertColumn() see MSDN.

    Good luck.

    --
    mailto://[email protected]

  4. #4
    Join Date
    Apr 1999
    Posts
    26

    Re: CListCtrl Question

    Try this up...
    int iTotalItem =m_ListControl.GetItemCount()
    m_ListControl.InsertItem(iTotalItem,"");
    m_ListControl.SetItemText(iTotalItem, 0,"Hello");



  5. #5
    Join Date
    May 1999
    Location
    Netherlands
    Posts
    57

    Re: CListCtrl Question

    if your CListCtrl is in report view, then you have to make the columns first.

    m_ListCtrl.InsertColumn(1,"Directory",LVCFMT_LEFT,140,-1);

    Mark


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