Thread: Display Title

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Malaysia
    Posts
    78
    Rep Power
    11

    Display Title


    For example
    Student No Student Name
    C1234 Jane
    C4567 Angel

    I wanna to display the Student No and Student Name at the top of the list box

    How??
    I hope someone can help me!!
    Programming is interesting
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    138
    Rep Power
    12
    I dont know what exactly you mean but from what i understand you can create two edit box and display the Student No and Student name
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Malaysia
    Posts
    78
    Rep Power
    11
    BOOL SuppList::OnInitDialog()
    {
    CDialog::OnInitDialog();
    char buf[1024];
    char *pch = NULL;
    ifstream myFile("Supplier.txt",ios::in);
    //
    CListCtrl m_SuppData;
    while(!myFile.eof())
    {
    myFile.getline(buf,1024);
    if ( isalnum(buf[0]) )
    {
    while ( (pch = strchr(buf, '|')) )
    pch[0] =' ';
    m_SuppData.InsertItem(buf);
    //m_SuppInfo.AddString(buf);
    }

    }
    // TODO: Add extra initialization here

    return TRUE; // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
    }

    So, i intend to change the list box to list control, because by doing this i may display the title use the InsertColumn method.

    But, error occur
    "Cannot convert parameter" when i change the code frm
    m_SuppInfo.AddString(buf);
    to

    m_SuppData.InsertItem(buf);

    Can u pls help me to look at this problem??
    Help me to debug it pls
    Programming is interesting
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    138
    Rep Power
    12
    I think the problem is with you passing a cstring parameter in the place of LVITEM this can be found in hte msdn help.


    int InsertItem(
    const LVITEM* pItem
    );
    int InsertItem(
    int nItem,
    LPCTSTR lpszItem
    );
    int InsertItem(
    int nItem,
    LPCTSTR lpszItem,
    int nImage
    };

    So to help your case i think you have to pass an integer say int i which increases to identify the item.
    so if you
    change ur code from
    m_SuppData.InsertItem(buf);
    m_SuppData.InsertItem(i,buf) i think it should solve your problem.


    Check that out and let me know
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Malaysia
    Posts
    78
    Rep Power
    11
    I am able to display the data using the code below

    BOOL SuppList::OnInitDialog()
    {
    CDialog::OnInitDialog();
    m_SuppData.InsertColumn(0, "Supplier Code", LVCFMT_LEFT,80);
    m_SuppData.InsertColumn(1, "Supplier Name", LVCFMT_LEFT, 85);

    char buf[1024];
    char *pch = NULL;
    ifstream myFile("Supplier.txt",ios::in);
    //
    int count=m_SuppData.GetItemCount();
    LVITEM lvitem;

    lvitem.pszText = "";
    lvitem.mask = LVIF_TEXT;
    lvitem.iItem = count;
    lvitem.iSubItem = 0;
    char* p = buf;
    //
    //CListCtrl m_SuppData;
    while(!myFile.eof())
    {
    myFile.getline(buf,1024);
    if ( isalnum(buf[0]) )
    {
    /*while ( (pch = strchr(buf, '|')) )
    pch[0] =' ';*/
    //m_SuppData.InsertItem(buf);
    //m_SuppInfo.AddString(buf);
    m_SuppData.InsertItem(&lvitem);
    m_SuppData.SetItemText(count, lvitem.iSubItem, p);
    }

    }
    // TODO: Add extra initialization here

    return TRUE; // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
    }

    But the data display at the same column.
    it only display at the dupplier code column
    m_SuppData.InsertColumn(0, "Supplier Code", LVCFMT_LEFT,80);

    U have any solution??
    Programming is interesting

IMN logo majestic logo threadwatch logo seochat tools logo