CListCtrl m_listLog;m_listLog.InsertColumn(0, "Name", LVCFMT_CENTER, 200);
m_listLog.InsertColumn(1, "Resource", LVCFMT_CENTER, 200);int nRow(0);
nRow = m_listLog.InsertItem(0, "str00");
m_listLog.SetItemText(nRow, 1, "str01");nRow = m_listLog.InsertItem(0, "str10");
m_listLog.SetItemText(nRow, 1, "str11");第二列开始,都可居中,为什么第一列不行呢?
m_listLog.InsertColumn(1, "Resource", LVCFMT_CENTER, 200);int nRow(0);
nRow = m_listLog.InsertItem(0, "str00");
m_listLog.SetItemText(nRow, 1, "str01");nRow = m_listLog.InsertItem(0, "str10");
m_listLog.SetItemText(nRow, 1, "str11");第二列开始,都可居中,为什么第一列不行呢?
解决方案 »
- CStdioFile打开绝对路径名的问题
- 如何把二进制数组数据批量的保存到数据库,采用ADO方式
- if (FAILED(hr))中的FAILED函数是什么含义?
- 日历控件的问题!~~~~~~~~~~~`
- 是vc++6.0出错了吗?
- 如何对所编写的动态连接库进行调试?
- 在窗口回调函数WndProc中调用一般函数,编译通过,连接错误的问题
- peon领分1
- 哪里有下 The C++ Programming Language中文版?
- 大家帮帮我这个小妹妹吧!
- 图像处理高手来看一下我公司的项目是否可行,技术上能否实现
- 内存管理(AWE)——完成端口通讯服务器(IOCP Socket Server)设计(二)
DrawText()
m_listLog.SetItemText(nRow, 1, "str01");nRow = m_listLog.InsertItem(0, "str10");把0该修改为1试下。。
m_listLog.SetItemText(nRow, 1, "str11");
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的列(最左边的列)如果设置了LVCFMT_RIGHT或LVCFMT_CENTER属性,上面的文字并不会右对齐或居中对齐。索引为0 的列是左对齐。如果你要想第一列右对齐或者居中对齐,你可以这样做,先保留索引为0的列,其他的列均指定右对齐或居中对齐属性,最后删除索引为0的列。下面是实例代码:
m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
CString str[] ={_T(""), _T("AAA"), _T("BBB"), _T("CCC"), _T("DDDD"), _T("EEE")};
for(int i=0; i<sizeof(str)/sizeof(str[0]); i++)
{
m_list.InsertColumn(i, str[i], LVCFMT_CENTER, 100);
m_list.InsertItem(i, _T(""));
m_list.SetItemText(i, 0, _T("AAA"));
}
m_list.DeleteColumn(0);
lvc.mask = LVCF_FMT;
m_list2.GetColumn(0, &lvc);
lvc.fmt &= ~LVCFMT_JUSTIFYMASK;
lvc.fmt |= LVCFMT_CENTER;
m_listLayer.SetColumn(0, &lvc);