(VS2010)MFC中List Control基本用法

来源:互联网 发布:香港银行开户 知乎 编辑:程序博客网 时间:2024/05/22 07:02
    //m_Infor_Msg为控件变量    //设置表头字体    CFont* m_title_font=new CFont;    m_title_font->CreatePointFont(120,"宋体");    m_Infor_Msg.SetFont(m_title_font);    m_Infor_Msg.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);//显示记录时所需的网格线    LV_COLUMN h;        //定义LV_COLUMN 结构对象    h.mask=LVCF_FMT|LVCF_TEXT|LVCF_WIDTH;       //设置对象h的fmt、pszText、cx有效    h.fmt=LVCFMT_CENTER;        //各个分栏居中显示    h.cx=82;                    //第一栏宽度、名称    h.pszText = _T("序号");    m_Infor_Msg.InsertColumn(0,&h);    h.cx=233;                   //第二栏宽度、名称    h.pszText = _T("测试项目名称");    m_Infor_Msg.InsertColumn(1,&h);    h.cx=233;    h.pszText = _T("状  态");    m_Infor_Msg.InsertColumn(2,&h);    //设置表格背景颜色、字体颜色、字体背景颜色    m_Infor_Msg.SetBkColor(RGB(0,150,0));    m_Infor_Msg.SetTextBkColor(RGB(0,150,0));    m_Infor_Msg.SetTextColor(RGB(255,200,0));    //要显示的内容事先保存在结构体Item中    //row为List中显示的行数    CString Itembuf;    CString numStr;    for(int i=0;i<row;i++)    {        numStr.Format(_T("%d"),i+1);//Item[i].ItemName;        m_Infor_Msg.InsertItem(i,numStr);        Itembuf=Item[i].ItemName;        m_Infor_Msg.SetItemText(i,1,Itembuf);        Itembuf=Item[i].ItemStatus;        m_Infor_Msg.SetItemText(i,2,Itembuf);    }   
原创粉丝点击