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

    CListCtrl Report View Columns

    Dear All,

    How can I add items of Text to a list control in report view to columns other 1?

    I thought the Item and iSubItem fields of LVITEM would fill in this information for me, but I can not get this to work.

    Any thought's or the correct solution I would be grateful.

    Regards
    Jason.




    // Taken from Header File. MFC Generated Code
    public:
    CLotteryDlg(CWnd* pParent = NULL); // standard constructor
    CHeaderCtrl *m_Header;

    // Dialog Data
    //{{AFX_DATA(CLotteryDlg)
    enum { IDD = IDD_LOTTERY_DIALOG };
    CListCtrl m_Results_List;
    //}}AFX_DATA



    //Taken from my OnInitDialog

    LVITEM jb2;
    ZeroMemory(&jb2,sizeof(jb2));

    jb2.mask=LVIF_TEXT;
    jb2.iItem=1;
    jb2.iSubItem=0;
    jb2.pszText="Jason";
    jb2.cchTextMax=20;


    m_Results_List.InsertColumn(0,"Date",LVCFMT_CENTER,100,-1);
    m_Results_List.InsertItem(&jb2);

    m_Results_List.InsertColumn(0,"1",LVCFMT_CENTER,20,-1);
    m_Results_List.InsertColumn(2,"2",LVCFMT_CENTER,20,-1);
    m_Results_List.InsertColumn(3,"3",LVCFMT_CENTER,20,-1);
    m_Results_List.InsertColumn(4,"4",LVCFMT_CENTER,20,-1);
    m_Results_List.InsertColumn(5,"5",LVCFMT_CENTER,20,-1);
    m_Results_List.InsertColumn(6,"6",LVCFMT_CENTER,20,-1);
    m_Results_List.InsertColumn(7,"B",LVCFMT_CENTER,20,-1);
    m_Results_List.InsertColumn(8,"Machine",LVCFMT_CENTER,70,-1);

    jb2.iItem=2;
    jb2.iSubItem=1;
    jb2.pszText="help";
    m_Results_List.InsertItem(&jb2);

    m_Results_List.UpdateWindow();

    // The result is that Only "Jason" gets added to Column 0 of the View.

    [email protected]

    please delete between the '-' cheers.


  2. #2
    Guest

    Re: CListCtrl Report View Columns

    Your on the right track. You need:

    m_Results_List.SetItem(&jb2);

    after InsetItem to update the 2-n columns, updating iSubItem for each column.

    Robert Clark



  3. #3
    Join Date
    May 1999
    Location
    UK
    Posts
    65

    Re: CListCtrl Report View Columns

    Robert, many thanks.

    Jason.


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