c++ - Listview Control No column headers -
i'm developing c++ mfc application. there have list view control.
- i define control variable (
m_listctrl
) underclistctrl
class ( resource view add variable ) - i add columns following code snippet
no column headers , columns. appreciated.
static void adddata(clistctrl &ctrl, int row, int col, const char *str) { lvitem lv; lv.iitem = row; lv.isubitem = col; lv.psztext = (lpstr)str; lv.mask = lvif_text; if (col == 0) ctrl.insertitem(&lv); else ctrl.setitem(&lv); } bool cmfctestdlg::oninitdialog() { //.. default code in mfc dialog here m_listctrl.insertcolumn(0, "page"); m_listctrl.setcolumnwidth(0, 60); m_listctrl.insertcolumn(1, "last modified"); m_listctrl.setcolumnwidth(1, 80); m_listctrl.insertcolumn(2, "prioirty"); m_listctrl.setcolumnwidth(2, 50); m_listctrl.sendmessage(lvm_setextendedlistviewstyle, 0, lvs_ex_fullrowselect); adddata(m_listctrl, 0, 0, "first"); adddata(m_listctrl, 0, 1, "jan 2011"); adddata(m_listctrl, 0, 2, "medium"); adddata(m_listctrl, 1, 0, "second"); adddata(m_listctrl, 1, 1, "feb 2011"); adddata(m_listctrl, 1, 2, "high"); return true; // return true unless set focus control }
because have dialog template have set style headers there.
click on control in resource editor. make sure have style report selected (section appearance, property view).
in section appearance, set no column header no
if create list view own code, don't use style lvs_nocolumnheader
the style column header define negative. set style if want suppress header. other styles defined positiv, want them set style. sometime confusing.
Comments
Post a Comment