listbox问题

wenjianyao 2003-10-15 02:23:29
1:怎么知道鼠标单击listbox中的每一条items,比如说有item1和item2两个,点击第一个showmessage(‘1111111’);点击第二个showmessage(‘2222222’);
2:如何获得listbox中有多少条数据?
...全文
36 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
caven 2003-10-15
  • 打赏
  • 举报
回复
ListBox1.Items.Count 字符串数

在TListBox 的 OnClick 过程中 加入

(Sender as TListBox).ItemIndex ;// 选取的字符串号数,从0开始的,单选时是这样

(Sender as TListBox).Selected[0] //返回boolean值,第0个字符串是否被选




huaervvhuaer 2003-10-15
  • 打赏
  • 举报
回复
1.
procedure TForm1.ListBox1Click(Sender: TObject);
begin
case listbox1.itemindex of
0:showmessage('000000');
1:showmessage('llllll');
2:showmessage('222222');
end;
end;

2.
listbox1.Items.Count

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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