Is there any example, code, tutorials that teaches you how to make multiple columns in a listview and then add the rows to it?
Thanks if you provide me some link:D
Printable View
Is there any example, code, tutorials that teaches you how to make multiple columns in a listview and then add the rows to it?
Thanks if you provide me some link:D
Would it be out of line to suggest MSDN?
I already looked at msdn but it has the whole explorer application which is a little hard to understand. That is why I want just some code that can add even one row to a multicolumn listview:)
When you send the add item message, you can specify in the LV(_)ITEM structure what subitem to add it to.
Send LVM_INSERTCOLUMN to insert a column and LVM_INSERTITEM to insert an item.
But how do I use it? I am posting the function that I am using to create a listview with two columns and then I am trying to add two items to each column in a row. But it is actually adding the items to only the first column on two rowsQuote:
Originally posted by parksie
When you send the add item message, you can specify in the LV(_)ITEM structure what subitem to add it to.
PHP Code:HWND CreateListView(HINSTANCE hinstance, HWND parenthwnd)
{
HWND lvhwnd;
INITCOMMONCONTROLSEX icex;
RECT rect;
LVCOLUMN lvc;
LVITEM lvi;
GetClientRect(parenthwnd, &rect);
// Ensure that the common control DLL is loaded.
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_LISTVIEW_CLASSES;
//Initialize the commoncontrols library
InitCommonControlsEx(&icex);
//Create the listview control
lvhwnd = CreateWindowEx(WS_EX_CLIENTEDGE,
WC_LISTVIEW,
"",
WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_EDITLABELS,
14,
65,
rect.right - 106,
rect.bottom - 155,
parenthwnd,
NULL,
hinstance,
NULL);
GetClientRect(lvhwnd, &rect);
//Add the columns the in the listview
lvc.mask = LVCF_WIDTH | LVCF_TEXT;
lvc.pszText = "Macro";
lvc.cx = rect.right /3;
ListView_InsertColumn(lvhwnd, 0, &lvc);
lvc.mask = LVCF_WIDTH | LVCF_TEXT;
lvc.pszText = "Macro Definition";
lvc.cx = rect.right - (rect.right /3);
ListView_InsertColumn(lvhwnd, 1, &lvc);
//Add the item in the listview
lvi.mask = LVIF_TEXT |LVIF_PARAM | LVIF_STATE;
lvi.pszText = "AAA";//LPSTR_TEXTCALLBACK; // sends an LVN_GETDISPINFO message.
lvi.iItem = 0;
lvi.state = 0;
lvi.stateMask = 0;
lvi.iSubItem = 0;
ListView_InsertItem(lvhwnd, &lvi);
lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
lvi.pszText = "AAA";//LPSTR_TEXTCALLBACK; // sends an LVN_GETDISPINFO message.
lvi.iItem = 0;
lvi.state = 0;
lvi.stateMask = 0;
lvi.iSubItem = 0;
ListView_InsertItem(lvhwnd, &lvi);
return lvhwnd;
}
Play around with this value :)Quote:
Code:lvi.iSubItem = 0;