社区
C#
帖子详情
listView1.Columns[6].Text="状态"; 怎么给该列赋值
js_hybintc
2011-07-20 03:45:52
如题
...全文
110
9
打赏
收藏
listView1.Columns[6].Text="状态"; 怎么给该列赋值
如题
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
9 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
xrongzhen
2011-07-20
打赏
举报
回复
[Quote=引用 6 楼 js_hybintc 的回复:]
行号和列号怎么确定
引用 2 楼 wxm3630478 的回复:
//是这个么
list.Items[rowindex].SubItems[columnindex].Text = "OK";
[/Quote]
行号 通过Index 或者你Item赋值时定义的Key
列号 第一列直接通过list.Items[rowindex].Text(或Value)赋值 从第二列开始用list.Items[rowindex].SubItems[columnindex-1].Text赋值
第一列也可以ist.Items[rowindex].SubItems[0].Text
dklali412
2011-07-20
打赏
举报
回复
获得行的索引看你在什么方法中执行楼上的代码了,如果在自己写的方法中你就遍历
for(int i=0;i<list.item.count;i++)
{
list.Items[i].SubItems[6].Text = "OK";
}
如果在listview自身的事件中,应该有e.rowindex吧。
wxm3630478
2011-07-20
打赏
举报
回复
[Quote=引用 6 楼 js_hybintc 的回复:]
行号和列号怎么确定
引用 2 楼 wxm3630478 的回复:
//是这个么
list.Items[rowindex].SubItems[columnindex].Text = "OK";
[/Quote]
列索引---你的问题已经说拉 6 或者 列的名字
行索引---就要看你具体代码时怎么写的啦...很多种方法可以获取到Item
js_hybintc
2011-07-20
打赏
举报
回复
行号和列号怎么确定
[Quote=引用 2 楼 wxm3630478 的回复:]
//是这个么
list.Items[rowindex].SubItems[columnindex].Text = "OK";
[/Quote]
js_hybintc
2011-07-20
打赏
举报
回复
item,没定义的啊
wxm3630478
2011-07-20
打赏
举报
回复
//是这个么
list.Items[rowindex].SubItems[columnindex].Text = "OK";
wxm3630478
2011-07-20
打赏
举报
回复
//是这个么
list.Items[rowindex].SubItems[columnindex].Text = "OK";
wxm3630478
2011-07-20
打赏
举报
回复
//是这个么
list.Items[rowindex].SubItems[columnindex].Text = "OK";
xuexiaodong2009
2011-07-20
打赏
举报
回复
listView1.Columns[6].item[0]="状态"试试
listview
基本用法
Delphi
ListView
基本用法大全(转)默认分类 2009-09-29 09:27:56 阅读138 评论0 字号:大中小 订阅 Delphi高级编程 Delphi文章 WEB开发 Delphi控件 Delphi
ListView
基本用法大全 作者:seeker 日期:2009-04-19 //增加项或列(字段)
ListView
1.Clear;
ListView
1.
Column
s.Clear;
ListView
1.
Column
s.Add;
ListView
1.
Column
s.Add;
ListView
1.
Column
s.Add;
ListView
1.
Column
s.Items[0].Caption:='id';
ListView
1.
Column
s.Items[1].Caption:='type';
ListView
1.
Column
s.Items[2].Caption:='title';
ListView
1.
Column
s.Items[2].Width:=300;
Listview
1.ViewStyle:=vsreport;
Listview
1.GridLines:=true; //注:此处代码也可以直接在可视化编辑器中完成, 也可写成以下这样 begin with
listview
1 do begin
Column
s.Add;
Column
s.Add;
Column
s.Add; ViewStyle:=vsreport; GridLines:=true;
column
s.items[0].caption:='进程名';
column
s.items[1].caption:='进程ID';
column
s.items[2].caption:='进程文件路径';
Column
s.Items[0].Width:=100;
Column
s.Items[1].Width:=100;
Column
s.Items[2].Width:=150; end end; //增加记录 with
listview
1.items.add do begin caption:='1212'; subitems.add('hh1'); subitems.add('hh2'); end; //删除
listview
1.items.delete(0); //从数据库表里读取数据写入
Listview
var Titem:Tlistitem; //此处一定要预定义临时记录存储变量. begin
ListView
1.Items.Clear; with adoquery1 do begin close; sql.Clear; sql.Add('select spmc,jg,sl from kcxs'); Open;
ListView
1.Items.Clear; while not eof do begin Titem:=
ListView
1.Items.add; Titem.Caption:=FieldByName('spmc').Value; Titem.SubItems.Add(FieldByName('sl').Value); Titem.SubItems.Add(FieldByName('jg').Value); next; end; //删除
ListView
1.DeleteSelected; //如何取得
ListView
中选中行的某一列的值 procedure TForm1.Button2Click(Sender: TObject); begin ShowMessage(
ListView
1.Selected.SubItems.Strings[1]); //返回选中行第三列中的值 end; showMessage(
listView
1.Selected.Caption); //返回选中行第一列的值. 第1列的值: -->>>
ListView
1.Selected.Caption 第i列的值(i>1):-->>>
ListView
1.Selected.SubItems.Strings[i]
ListView
1.Items.Item[1].SubItems.Get
Text
); //取得
listview
某行某列的值 Edit2.
Text
:=
listview
1.Items[i].SubItems.strings[0]; //读第i行第2列 返回选中行所有子列值.是以回车符分开的,你还要从中剥离出来你要的子列的值。 showMessage(
ListView
1.Selected.SubItems.Get
Text
);
ListView
简单排序的实现
ListView
排序 怎样实现单击一下按升序,再单击一下按降序。 function CustomSortProc(Item1, Item2: TListItem;
Column
Index: integer): integer; stdcall; begin if
Column
Index = 0 then Result := Compare
Text
(Item1.Caption,Item2.Caption) else Result := Compare
Text
(Item1.SubItems[
Column
Index-1],Item2.SubItems[
Column
Index-1]) end; procedure TFrmSrvrMain.
ListView
1
Column
Click(Sender: TObject;
Column
: TList
Column
); begin
ListView
1.CustomSort(@CustomSortProc,
Column
.Index); end; =============================================================== //增加 i :=
ListView
1.Items.Count; with
ListView
1 do begin ListItem:=Items.Add; ListItem.Caption:= IntToStr(i); ListItem.SubItems.Add('第 '+IntToStr(i)+' 行'); ListItem.SubItems.Add('第三列内容'); end; //按标题删除 for i:=
ListView
1.Items.Count-1 downto 0 Do if
ListView
1.Items[i].Caption = Edit1.
Text
then begin
ListView
1.Items.Item[i].Delete(); //删除当前选中行 end; //选中一行 if
ListView
1.Selected <> nil then Edit1.
Text
:=
ListView
1.Selected.Caption; //
listview
1.Items[
Listview
1.Items.Count -1].Selected := True; //
listview
1.Items[
Listview
1.Items.Count -1].MakeVisible(True); procedure TForm1.Button2Click(Sender: TObject); // 选择第一条 begin
listview
1.SetFocus;
listview
1.Items[0].Selected := True; end; procedure TForm1.Button1Click(Sender: TObject); // 选择最后一条 begin
listview
1.SetFocus;
listview
1.Items[
Listview
1.Items.Count -1].Selected := True; end; //这是个通用的过程 procedure
ListView
ItemMoveUpDown(lv : T
ListView
; Item : TListItem; MoveUp, SetFocus : Boolean); var DestItem : TListItem; begin if (Item = nil) or ((Item.Index - 1 < 0) and MoveUp) or ((Item.Index + 1 >= lv.Items.Count) and (not MoveUp)) then Exit; lv.Items.BeginUpdate; try if MoveUp then DestItem := lv.Items.Insert(Item.Index - 1) else DestItem := lv.Items.Insert(Item.Index + 2); DestItem.Assign(Item); lv.Selected := DestItem; Item.Free; finally lv.Items.EndUpdate; end; if SetFocus then lv.SetFocus; DestItem.MakeVisible(False); end; //此为调用过程,可以任意指定要移动的Item,下面是当前(Selected)Item
ListView
ItemMoveUpDown(
ListView
1,
ListView
1.Selected, True, True);//上移
ListView
ItemMoveUpDown(
ListView
1,
ListView
1.Selected, False, True);//下移 T
ListView
组件使用方法 引用CommCtrl单元 procedure TForm1.Button1Click(Sender: TObject); begin
ListView
_Delete
Column
(My
ListView
.Handle, i);//i是要删除的列的序号,从0开始 end; 用
LISTVIEW
显示表中的信息: procedure viewchange(listv:t
listview
;table:tcustomadodataset;var i:integer); begin t
listview
(listv).Items.BeginUpdate; {listv:
listview
名} try t
listview
(listv).Items.Clear; with table do {table or query名} begin active:=true; first; while not eof do begin listitem:=t
listview
(listv).Items.add; listitem.Caption:=trim(table.fields[i].asstring); // listitem.ImageIndex:=8; next; end; end; finally t
listview
(listv).Items.EndUpdate; end; end;
ListView
使用中的一些要点。以下以一个两列的
ListView
为例。 →增加一行: with
ListView
1 do begin ListItem:=Items.Add; ListItem.Caption:='第一列内容'; ListItem.SubItems.Add('第二列内容'); end; →清空
ListView
1:
ListView
1.Items.Clear; →得到当前被选中行的行的行号以及删除当前行: For i:=0 to
ListView
1.Items.Count-1 Do If
ListView
1.Items[i].Selected then //i=
ListView
1.Selected.index begin
ListView
1.Items.Delete(i); //删除当前选中行 end; 当然,
ListView
有OnSelectItem事件,可以判断选择了哪行,用个全局变量把它
赋值
出来。 →读某行某列的操作: Edit1.
Text
:=
listview
1.Items[i].Caption; //读第i行第1列 Edit2.
Text
:=
listview
1.Items[i].SubItems.strings[0]; //读第i行第2列 Edit3.
Text
:=
listview
1.Items[i].SubItems.strings[1]; //读第i行第3列 以次类推,可以用循环读出整列。 →将焦点上移一行: For i:=0 to
ListView
1.Items.Count-1 Do If (
ListView
1.Items[i].Selected) and (i>0) then begin
ListView
1.SetFocus;
ListView
1.Items.Item[i-1].Selected := True; end; 不过在Delphi6中,
ListView
多了一个ItemIndex属性,所以只要
ListView
1.SetFocus;
ListView
1.ItemIndex:=3; 就能设定焦点了。 Delphi的
listview
能实现交替颜色么? procedure TForm1.
ListView
1CustomDrawItem( Sender: TCustom
ListView
; Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean); var i: integer; begin i:= (Sender as T
ListView
).Items.IndexOf(Item); if odd(i) then sender.Canvas.Brush.Color:= $02E0F0D7 else sender.Canvas.Brush.Color:= $02F0EED7; Sender.Canvas.FillRect(Item.DisplayRect(drIcon)); end; 要想随时更改
ListView
中某一行的字体颜色,要在
ListView
的 OnCustomDrawItem 的事件中书写相关的代码。例如 我想更改选中的某行字体的颜色,则需要在事件中写入下的代码: if item.Index = strtoint(edit1.
Text
) then //该条件是用于判断是否符合更改字体颜色的行的条件。 Sender.Canvas.Font.Color := clred;
ListView
基本用法大全
Delphi
ListView
基本用法大全//增加项或列(字段)
ListView
1.Clear;
ListView
1.
Column
s.Clear;
ListView
1.
Column
s.Add;
ListView
1.
Column
s.Add;
ListView
1.
Column
s.Add;
ListView
1.
Column
s.Items[0].Caption:=’id’;
ListView
1.
Android核心组件
ListView
详解
在Android所有常用的原生控件当中,用法最复杂的应该就是
ListView
了,它专门用于处理那种内容元素很多,手机屏幕无法展示出所有内容的情况。... 1,
ListView
介绍; 2,原理讲解; 3,简单实现; 4,
ListView
扩展;
【经验】Delphi
ListView
基本用法大全
//增加项或列(字段)
ListView
1.Clear;
ListView
1.
Column
s.Clear;
ListView
1.
Column
s.Add;
ListView
1.
Column
s.Add;
ListView
1.
Column
s.Add;
ListView
1.
Column
s.Items[0].Caption:=&apos;id&apos;;
ListView
1.Colum...
java
listview
取值_(转)
Listview
取值,与
赋值
转自:http://hi.baidu.com/kr1423/blog/item/a19d9c18542e98b14aedbcba.html
ListView
1.Items 为标准 Tlistitems类
ListView
1.Items(1)
赋值
with
ListView
1.Items.Add dobeginCaption:=caption; //添加第一项SubItems.add(aaaaa); //...
C#
110,538
社区成员
642,577
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章