ListControl:基本属性:

View: 图标显示风格

具体代码如下:

MFC的基本控件的使用~列表控件(ListControl)的使用

CString str1[] = {_T("数字"),_T("字母")};
    for (int i = 0; i < 2; i++)
    {
        //设置表头  1. 索引值  2. 内容 3. 对齐方式 4.列宽
        m_listcontrl.InsertColumn(i,str1[i],LVCFMT_LEFT,200);
    }
    //设置正文
    //插入数据
    m_listcontrl.InsertItem(0,_T("0"));
    //给某个item 插入值    1. 第一行 2. 第几列 3. 插入的数据
    m_listcontrl.SetItemText(0, 1, _T("A"));
    m_listcontrl.InsertItem(1, _T("1"));
    m_listcontrl.SetItemText(1, 1, _T("B"));
    //设置整行选中LVS_EX_FULLROWSELECT 整行选中    LVS_EX_GRIDLINES  网格显示
    m_listcontrl.SetExtendedStyle(m_listcontrl.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
    //删除  某个列表项
    m_listcontrl.DeleteItem(0);
    //删除某一列
    //m_listcontrl.DeleteColumn(0);
    CString str2;
    int strCur;
    //获取文本 。参数1指定了列表项的索引,参数2指定了列表子项的索引。
    /*str2 = m_listcontrl.GetItemText(0,1);
    MessageBox(str2);*/
    //设置某个值 参数1指定了列表项的索引,参数2指定了列表子项的索引。
    m_listcontrl.SetItemText(0,1,_T("3"));

 

相关文章:

  • 2022-01-25
  • 2021-10-05
  • 2021-04-21
  • 2021-10-03
  • 2021-09-29
  • 2021-12-12
  • 2021-11-02
猜你喜欢
  • 2021-07-16
  • 2021-11-14
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
相关资源
相似解决方案