[MFC] List Control第一列为什么无法居中?
来源:互联网 发布:怎么能提高淘宝销量 编辑:程序博客网 时间:2024/05/16 09:22
事实是微软规定第一列式不能设置格式,MSDN里有说明:
If a column is added to a list-view control with index 0 (the leftmost column) and with LVCFMT_RIGHT or LVCFMT_CENTER specified, the text is not right-aligned or centered. The text in the index 0 column is left-aligned. Therefore if you keep inserting columns with index 0, the text in all columns are left-aligned. If you want the first column to be right-aligned or centered you can make a dummy column, then insert one or more columns with index 1 or higher and specify the alignment you require. Finally delete the dummy column.
要想设置第一列为居中,可以在插入时将索引为0的列作为保留,插完所有列后删除第0列,此后对表格的访问索引依然会从0开始,即使一开始没有对此进行处理,也不需要修改后面的处理代码。
m_list_objclasses.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);m_list_objclasses.InsertColumn(0,"保留",LVCFMT_CENTER);m_list_objclasses.InsertColumn(1,"类名",LVCFMT_CENTER);m_list_objclasses.InsertColumn(2,"库名",LVCFMT_CENTER);m_list_objclasses.InsertColumn(3,"属性",LVCFMT_CENTER);m_list_objclasses.InsertColumn(4,"实例",LVCFMT_CENTER);m_list_objclasses.DeleteColumn(0);<span style="white-space:pre"></span>//删除第0列m_list_objclasses.SetColumnWidth(0,100);//依然从0开始访问m_list_objclasses.SetColumnWidth(1,110);m_list_objclasses.SetColumnWidth(2,70);m_list_objclasses.SetColumnWidth(3,143);效果如下:
参考:http://bbs.csdn.net/topics/330257954
0 0
- [MFC] List Control第一列为什么无法居中?
- [转]MFC list control
- MFC List Control总结
- mfc list control 用法
- MFC List Control控件
- datasetexcel 为空 无法获取列为什么出差,
- MFC list control 的使用
- 【MFC】实现 List Control 翻页
- MFC控件之list control
- MFC中的List Control学习
- MFC如何使用 List Control
- MFC List Control自动滚动
- MFC控件(5):List Control
- VC++ 6.0 MFC List Control
- MFC List Control滚动条
- MFC ListControl用法(List Control)
- MFC list Control 控件设置
- MFC List Control 报表使用方法
- mac上配置LUA
- OC @autorelease
- Win10-Win7下jdk1.8环境配置教程
- 杭电1173(采矿)
- Android优化——UI优化(一)
- [MFC] List Control第一列为什么无法居中?
- 1.HCNP-R&S-IERN——OSPF路由协议基础
- 开始对EEG数据进行训练
- First steps of using googleVis on shiny
- Windows 中 Boost 库安装简要
- UIImage+iPhone5 自动判断设备是否iPhone5,并选择相应的背景图
- 斐波那契数列 递推 递归 备忘录 动态规划
- 新建的xib中找不到Simulated Metrics解决办法
- Description Resource Path LocationType Java compiler level does not match the version of the instal