A simple question about CListCtrl::InsertItem
-
This is a simple question, I'm sure you have the answer, help me out please. I have a List control in my dialog, to which I associate a member variable of CListCtrl. The style of this control is: General: Visible, Tab stop Styles: View-Report, Align-Left, Sort-None, Single Selection, Edit Labels, No column header, Show selection always More Styles: Border Extended Styles: Static edge. In the OnInitDialog, I had the following: m_myListCtrl.InsertItem(0, "item 0"); But when the dialog is displayed, nothing in the list control!:mad::mad: What am I missing?
-
This is a simple question, I'm sure you have the answer, help me out please. I have a List control in my dialog, to which I associate a member variable of CListCtrl. The style of this control is: General: Visible, Tab stop Styles: View-Report, Align-Left, Sort-None, Single Selection, Edit Labels, No column header, Show selection always More Styles: Border Extended Styles: Static edge. In the OnInitDialog, I had the following: m_myListCtrl.InsertItem(0, "item 0"); But when the dialog is displayed, nothing in the list control!:mad::mad: What am I missing?
-
sigh, it turned out that I have to do more overhead work: m_myListCtrl.InsertColumn(0, "First Column", LVCFMT_LEFT, nWidth); m_myListCtrl.InsertItem(0, "my item"); beats me! X|
:)hi, this is what we do.. as m_List.InsertColumn( // Ask Mfc to create/insert a column 0, // This is the rank/order of this // particular item "Name", // The caption we want for this header LVCFMT_LEFT, // The relative position we want the // items under this header to have 100); // The width we want for the items under // this header m_List.InsertColumn(1, "Profession", LVCFMT_CENTER, 80); m_List.InsertColumn(2, "Fav. Sport", LVCFMT_LEFT, 100); m_List.InsertColumn(3, "Hobby", LVCFMT_LEFT, 80); and to add items.. provide some items to display under the headers: int nItem; // This integer will be used to identify the // header item we are dealing with. // Give a name/caption to an item to display under the first header nItem = m_List.InsertItem(0, "Sandra"); // Create a caption for the corresponding headers. m_List.SetItemText(nItem, 1, "Singer"); m_List.SetItemText(nItem, 2, "HandBall"); m_List.SetItemText(nItem, 3, "Beach"); i hope so you get..why you were getting an error.. cheers Himanshu
-
:)hi, this is what we do.. as m_List.InsertColumn( // Ask Mfc to create/insert a column 0, // This is the rank/order of this // particular item "Name", // The caption we want for this header LVCFMT_LEFT, // The relative position we want the // items under this header to have 100); // The width we want for the items under // this header m_List.InsertColumn(1, "Profession", LVCFMT_CENTER, 80); m_List.InsertColumn(2, "Fav. Sport", LVCFMT_LEFT, 100); m_List.InsertColumn(3, "Hobby", LVCFMT_LEFT, 80); and to add items.. provide some items to display under the headers: int nItem; // This integer will be used to identify the // header item we are dealing with. // Give a name/caption to an item to display under the first header nItem = m_List.InsertItem(0, "Sandra"); // Create a caption for the corresponding headers. m_List.SetItemText(nItem, 1, "Singer"); m_List.SetItemText(nItem, 2, "HandBall"); m_List.SetItemText(nItem, 3, "Beach"); i hope so you get..why you were getting an error.. cheers Himanshu
-
Thank you, Himanshu. I got it now. This list control is more complext to use than those combo box and edit control. :(
Yes first you have to insert columns, then you can insert rows as items. Finally you can set each columns values for that new item : InsertColumn, InsertItem, SetItem for each column... Hope it helps, JM Earth > Europe > France > Lyon