listview1.Columns[0].Caption:='xxx';
listview1.Columns[1].Caption:='xxx1';
listview1.Columns[2].Caption:='xxx2';
你的ListView的Columns是否动态生成的?
可以用ListView.Items.Add。
你最好把错误信息贴出来,方便大家参考
listview1.Columns[1].Caption:='xxx1';
listview1.Columns[2].Caption:='xxx2';
你的ListView的Columns是否动态生成的?
可以用ListView.Items.Add。
你最好把错误信息贴出来,方便大家参考
解决方案 »
- 关于idhttp post的几个问题
- 如何实现将PageControl的箭头分别置两边?
- 升角,散分(内含非常规笑话)
- 数字中间加空格 (1 2 3 4 5 6)
- Delphi中有没有象VB的DoEvents的函数,即能让程序在执行循环时还能执行其他操作(如刷新窗口)。
- 如何做一个下载软件,需要用到什么控件?100分相送.绝不食言.在线等待
- 请问如何让程序在制定的点,停止一秒在执行.
- 怎样让程序最小化时和qq一样隐藏在状态栏??(在线等待)
- 凭证控件的问题
- 已经第三次贴了,高手指教一下呀
- 我用ADO连接数据库,怎么用相对路径。
- 怎样写播放MPEG One 文件的程序 Delphi自带的控件好像不行
Names: array[0..5, 0..1] ofstring = (
('Rubble', 'Barney'),
('Michael', 'Johnson'),
('Bunny', 'Bugs'),
('Silver', 'HiHo'),
('Simpson', 'Bart'),
('Squirrel', 'Rocky')
);var
I: Integer;
NewColumn: TListColumn;
ListItem: TListItem;
ListView: TListView;
begin
ListView := TListView.Create(Self);
with ListView do
begin
Parent := Self;
Align := alClient; ViewStyle := vsReport; NewColumn := Columns.Add;
NewColumn.Caption := 'Last';
NewColumn := Columns.Add;
NewColumn.Caption := 'First'; for I := Low(Names) to High(Names) do
begin
ListItem := Items.Add;
ListItem.Caption := Names[I][0];
ListItem.SubItems.Add(Names[I][1]);
end;
end;
end;
你的代码好象和我的一样。: luoweicaisd(笑三少) (
我是想问我的代码错在哪里,如何更正
如果能用
ListView.Items.Add(),那()里的参数是什么?
出错的原因是listview1.Columns的数量是0,你需要创建
创建方式NewColumn: TListColumn;
begin
with listview1 do
begin
NewColumn := Columns.Add;
NewColumn.Caption := 'Last';
NewColumn := Columns.Add;
NewColumn.Caption := 'First';
end;
listitem:Tlistitem;
begin
listitem:=ListView1.Items.Add;
ListItem.Caption:='XXX';
listitem.SubItems.Add('XXX1');
listitem.SubItems.Add('XXX2');
ListView1.Columns.Add ;
listview1.Columns[0].Caption:='xxx';
ListView1.Columns.Add ;
listview1.Columns[1].Caption:='xxx1';
ListView1.Columns.Add ;
listview1.Columns[2].Caption:='xxx2';
把你的程序后面三句去掉
然后再oncustomdrawitem
oncustomdrawsubitem
里面加代码
你的代码是正确的,但我还想问一下,
如果我想加入第二行呢?(如,1,2,3)比如刚才的XXX,XXX1,XXX2是第一行。给出答案后马上给分,谢谢大家
var
listitem, listitem1: Tlistitem;
begin
listitem := ListView1.Items.Add;
ListItem.Caption := 'XXX';
listitem.SubItems.Add('XXX1');
listitem.SubItems.Add('XXX2');
listitem1 := listview1.items.add;
ListItem1.Caption := '1';
listitem1.SubItems.Add('2');
listitem1.SubItems.Add('3');
//listitem.SubItems.Add('XXX3'); ListView1.Columns.Add;
listview1.Columns[0].Caption := 'xxx';
ListView1.Columns.Add;
listview1.Columns[1].Caption := 'xxx1';
ListView1.Columns.Add;
listview1.Columns[2].Caption := 'xxx2';
end;
给分