请问如何添加List Control 的标题栏?急,在线等

pifulu 2003-08-20 10:07:21
请问如何添加List Control 的标题栏?我手边的书上正好没有。
急!在线等,谢谢!
...全文
128 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
pifulu 2003-08-22
  • 打赏
  • 举报
回复
我明白错处了。和我问的没什么关系,大家说的都对。主要是我对指针的操作搞不清楚,误定义了一个对话框的对象,又没有赋值。所以错误上才会说没有创建窗口云云。其实我本来只是想通过对象来初始化ListControl的
cwming 2003-08-21
  • 打赏
  • 举报
回复
把你的插入行的代码传上来让我们看看,我想大家都会明白问题出处。
pifulu 2003-08-20
  • 打赏
  • 举报
回复
up
xiaohedou 2003-08-20
  • 打赏
  • 举报
回复
你看一下这里:不仅可以写标题栏,还可以有skin皮肤,水平垂直控制:

http://www.codeproject.com/useritems/skinlist.asp#xx583272xx


How to skin CListCtrl including scrollbars and column headers
By Greg Ellis

This article will show you how to skin a CListCtrl including the CHeaderCtrl and the scrollbars. You will be able to totally customize the look and feel of almost all the aspects of a CListCtrl.
wuchuncai 2003-08-20
  • 打赏
  • 举报
回复
//m_DbfList为一ListControl
int Column;
LV_COLUMN LVColumn;

LVColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
{
for (Column = 0; Column < 8; Column++)
{
CString HeaderString;

// fill header data
LVColumn.iSubItem = Column;
LVColumn.pszText = (LPTSTR) (LPCTSTR)m_ColumnLabelStr[Column];
LVColumn.cx = lstrlen(m_ColumnLabelStr[Column])*16;
LVColumn.fmt = LVCFMT_CENTER ;
m_DbfList.InsertColumn (Column, &LVColumn);
}
}
pifulu 2003-08-20
  • 打赏
  • 举报
回复
为什么会出现这种错误?
Debug Assertion Failed!

Program:.....
File: afxcmn.inl
Line: 186

For imformation on how your program can cause an assertion
failure, see Visual C++ document on asserts.

(Press Retry to debug this appliation)


我的listcontrol 是report型的
chenweihello 2003-08-20
  • 打赏
  • 举报
回复
标题拦??setwindowtext(titlestr);
xjl930 2003-08-20
  • 打赏
  • 举报
回复
CListCtrl myList;

myList.InsertColumn(0,_T("column1"),LVCFMT_LEFT,200,-1);
myList.InsertColumn(1,_T("column2"),LVCFMT_LEFT,100,-1);
.........
pifulu 2003-08-20
  • 打赏
  • 举报
回复
我比较菜,刚开始学,请说得详细点
谢谢
vcforever 2003-08-20
  • 打赏
  • 举报
回复
CListCtrl m_ctlList;
DWORD m_style;
m_style = LVS_EX_FULLROWSELECT
|LVS_EX_FRIDLINES
|LVS_EX_ONECLICKACTIVATE;
m_ctlList.InsertColum(.......);
m_ctlList.SetExtendedStyle(m_style);
pifulu 2003-08-20
  • 打赏
  • 举报
回复
问题应该不在属性那里,我不论设置什么属性总是出现debug error
只是可能文件不同

创建窗口?用什么函数?
对话框上已经有了这个控件了
难道不是CListCtrl m_ListRecords;以后就可以设置属性了?
wangbab 2003-08-20
  • 打赏
  • 举报
回复
楼上的解答都对。
Program:.....
File: afxcmn.inl
Line: 186

For imformation on how your program can cause an assertion
failure, see Visual C++ document on asserts.

我查看了afxcmn.inl的186行,为
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem); }

估计为你没有初始化,ListCtrl还没有创建窗口。


cwming 2003-08-20
  • 打赏
  • 举报
回复
如果还不行干脆不要:
m_ctListCtrl.SetExtendedStyle(m_ctListCtrl.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_TRACKSELECT | LVS_EX_GRIDLINES);
cwming 2003-08-20
  • 打赏
  • 举报
回复
好象是设置 LVS_EX_FULLROWSELECT 出错,你把这个属性去掉试试,顺便问问怎样设置选择整行? yushulei(永远)应该知道吧!

LV_COLUMN lvc;
lvc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH;

//For ITEM.
//设置列表
lvc.iSubItem = 0;
lvc.pszText = _T("节点名称");
lvc.cx = 100;
dblist.InsertColumn(0,&lvc);
lvc.iSubItem = 1;
lvc.pszText = _T("对象ID");
lvc.cx = 100;
dblist.InsertColumn(1,&lvc);
lvc.iSubItem = 2;
lvc.pszText = _T("版本");
lvc.cx = 100;
dblist.InsertColumn(2,&lvc);
lvc.iSubItem = 3;
lvc.pszText = _T("系统命令");
lvc.cx =100;
dblist.InsertColumn(3,&lvc);
lvc.iSubItem = 4;
lvc.pszText = _T("参数");
lvc.cx =75;
dblist.InsertColumn(4,&lvc);
lvc.iSubItem = 5;
lvc.pszText = _T("配置对象个数");
lvc.cx =85;
dblist.InsertColumn(5,&lvc);
lvc.iSubItem = 6;
lvc.pszText = _T("实际对象个数");
lvc.cx =85;
dblist.InsertColumn(6,&lvc);
pifulu 2003-08-20
  • 打赏
  • 举报
回复
有谁能告诉我,为什么总会出现这种错误?
究竟是哪里错了?

Debug Assertion Failed!

Program:.....
File: afxcmn.inl
Line: 186

For imformation on how your program can cause an assertion
failure, see Visual C++ document on asserts.

(Press Retry to debug this appliation)
bluestar 2003-08-20
  • 打赏
  • 举报
回复
m_listReport.InsertColumn(0, "1", LVCFMT_CENTER, 100); //长度100,放正中的标题
m_listReport.InsertColumn(1, "2", LVCFMT_CENTER, 100);

………………
依次类推
yushulei 2003-08-20
  • 打赏
  • 举报
回复
m_ctListCtrl.SetExtendedStyle(m_ctListCtrl.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_TRACKSELECT | LVS_EX_GRIDLINES); //设置他的风格
m_ctListCtrl.InsertColumn(0,"One",LVCFMT_LEFT,150,150);
//参数依次为:第零列,列名,左对齐,长宽(这个忘了那个在前了,你试一下就知道了)
m_ctListCtrl.InsertColumn(1,"Two",LVCFMT_LEFT,150,150);
m_ctListCtrl.InsertColumn(2,"Three",LVCFMT_LEFT,150,150);
for (int i=0;i<20;i++)
{
CString str;
str.Format("John%d",i);
m_ctListCtrl.InsertItem(i,_T(str));
m_ctListCtrl.SetItemText(i,1,_T("Paul"));
m_ctListCtrl.SetItemText(i,2,_T("Ringo"));
//i为行,1,2分别为列,后面的为内容
}

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧