• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
萱纸
博客园    首页    新随笔    联系   管理    订阅  订阅
mfc 列表控件
经常使用的mfc控件:list control,记录下
 
  1. 首先将list control拖入到对话框中,然后命名ID,通过类向导,类型为control,控件变量名(m_showlist),  view改变为report报表形式
  2. 在xxxDlg.cpp::OnInitDialog()根据需要添加表头和表项内容
          eg:  
CRect rect;
m_showlist.GetClientRect(&rect);
m_showlist.SetExtendedStyle(m_showlist.GetExStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
//表头
m_showlist.InsertColumn(0,_T("身份证号"), LVCFMT_CENTER,rect.Width()/5,0);
m_showlist.InsertColumn(1,_T("姓名"), LVCFMT_CENTER,rect.Width()/5,1);
m_showlist.InsertColumn(2,_T("类型"), LVCFMT_CENTER,rect.Width()/5,2);
m_showlist.InsertColumn(3,_T("发证日期"), LVCFMT_CENTER,rect.Width()/5,3);
m_showlist.InsertColumn(4,_T("有效期"), LVCFMT_CENTER,rect.Width()/5,4);
//表项
  1. 然后通过函数 SetItemText 修改表格的内容
                  m_showlist.SetItemText(i, j, string);
                     其中,表示将第 i 列 第 j 行 内容改为 字符串 string 
                    例子:m_list_goods.SetItemText(1,2,_T("未拍卖"));
posted on 2017-10-14 15:35  xuanzhi  阅读(1273)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3