Help Needed - How to draw Gridlines in ListBox (Non MFC) Win32
Hi all.. i'm having a problem with the Listbox control in a Window. I need to display Gridlines(Horizontical lines) in the listbox control.
I Searched the MSDN Documentation and found that, the LVS_EX_GRIDLINES style setting can do it for me.. and also, it must be used in conjunction with LVS_REPORT style.
I tried, but was in vein.. nothing happened.. i used the ListView_SetExtendedStyleView() API and also tried out using the SendMessage() API... And that too failed.
I searched google for sample codes, but didnt find any useful.. there are soo many codes and articles on MFC, but i dont know MFC.. i need only Win32 code.
Re: Help Needed - How to draw Gridlines in ListBox (Non MFC) Win32
Again, LB_ADDSTRING is a message for lisbox and not for listview (this two are quite different controls).
To a listview you have to send LVM_xxx messages.
Here is a brief examples which fills a listview with two lines and two columns.
Code:
// add two columns
LVCOLUMN lvc = {0};
lvc.mask = LVCF_TEXT|LVCF_FMT|LVCF_WIDTH|LVCF_SUBITEM;
lvc.pszText = _T("Column 0"); // text
lvc.fmt = LVCFMT_LEFT; // left align text
lvc.cx = 100; // column width
lvc.iSubItem = 0; // subitem
ListView_InsertColumn(hList, 0, &lvc);
lvc.pszText = _T("Column 1"); // text
lvc.iSubItem = 1; // subitem
ListView_InsertColumn(hList, 1, &lvc);
LVITEM lvi = {0};
// add two "empty" items ("rows" for a report style listview)
lvi.iItem = 0; // item index
ListView_InsertItem(hList, &lvi);
lvi.iItem = 1;
ListView_InsertItem(hList, &lvi);
// set items/subitems text
ListView_SetItemText(hList, 0, 0, _T("line 0, col 0"));
ListView_SetItemText(hList, 0, 1, _T("line 0, col 1"));
ListView_SetItemText(hList, 1, 0, _T("line 1, col 0"));
ListView_SetItemText(hList, 1, 1, _T("line 1, col 1"));
Last edited by ovidiucucu; April 23rd, 2009 at 11:19 AM.
Re: Help Needed - How to draw Gridlines in ListBox (Non MFC) Win32
@ ovidiucucu
Thanks again bro.. your help is very very appreciative. thanks for sparing your valuable time to prepare a small snippet.
Actually i wansn't awared about the SysListView32 control. Now i learnt many things about that control.. and surely i read MSDN and got more API's related to this control.
@ Carl666
can you please tell more detail about MS Grid? Sorry, i didnt find a match in the MSDN Documentation. can you atleast tell me the corect classname? is it advanced than the listview control?
Bookmarks