社区
C++ Builder
帖子详情
怎样得到ListBox控件中Items数量?
tenix
2003-10-16 08:12:39
即返回最后一个ItemIndex.
...全文
194
3
打赏
收藏
怎样得到ListBox控件中Items数量?
即返回最后一个ItemIndex.
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
tenix
2003-10-16
打赏
举报
回复
马上给分。
fatwave
2003-10-16
打赏
举报
回复
ListBox1->Items->Count
GeoPhoenix
2003-10-16
打赏
举报
回复
ListBox1->Items->Count
C#入门教程之
ListBox
控件
使用方法
ListBox
控件
的使用: 1)
控件
属性
Items
Selected
Items
SelectioModes 2)数据绑定 DataSoure DisplayMember ValueMenber 3)实例 下面开始一一说明上面的
ListBox
控件
的使用。 首先来说
控件
的属性, (1)
Items
:使用此属性获取列表
控件
项的属性。此属性可用于确定列表
控件
中
的选定项。添加
items
时既可以设计时静态添加,也可以在代码
中
动态添加。如果不想显示设计时添加的
items
,可以在代码
中
添加this.
listBox
1.
Items
.Clear();只显示在代码
中
添加的选项。 (2)Selected
Items
:获取
Delphi
控件
大全.doc
控件
使用 Standard页 1- T
listbox
控件
重要属性
items
.* 举例,界面设计如下左,执行结果如下右: 代码为 procedure TForm1.Button1Click(Sender: TObject); begin edit1.Text :=
listbox
1.
Items
.CommaText; edit2.Text :=
listbox
1.
Items
.Text; edit3.Text :=
listbox
1.
Items
.GetNamePath; edit4.Text :=
listbox
1.
Items
.Strings[1]; edit5.Text :=
listbox
1.
Items
.DelimitedText; edit6.Text :=
listbox
1.
Items
.Names[1]; end; 由执行结果知,CommaText把各行用逗号隔开,Text获得所有行数字符且不隔开,Strings[i]获得i行的字符。
NET SmartControls 分页
控件
SmartControls
控件
扩展Demo源码 GridView/DropDownList/TreeView/
ListBox
的扩展 扩展GridView
控件
: 自定义分页样式。显示总记录数、每页记录数、当前页数、总页数、首页、上一页、下一页、末页和分页按钮 扩展DropDownList
控件
和
ListBox
控件
- 支持分组功能(optgroup标签) DropDownList(
ListBox
)
控件
既强大又好用。为了让它更强大、更好用,我们来写一个继承自DropDownList(
ListBox
)的
控件
。 扩展DropDownList
控件
和
ListBox
控件
- 支持分组功能(optgroup标签) 介绍 扩展DropDownList
控件
和
ListBox
控件
: 通过DropDownList
控件
和
ListBox
控件
的.
Items
.Add(ListItem item)方法,来为其添加optgroup标签,从而实现分组功能 可以导出Excel或Word
SmartControls
控件
扩展Demo源码
SmartControls
控件
扩展Demo源码 GridView/DropDownList/TreeView/
ListBox
的扩展 扩展GridView
控件
: 自定义分页样式。显示总记录数、每页记录数、当前页数、总页数、首页、上一页、下一页、末页和分页按钮 扩展DropDownList
控件
和
ListBox
控件
- 支持分组功能(optgroup标签) DropDownList(
ListBox
)
控件
既强大又好用。为了让它更强大、更好用,我们来写一个继承自DropDownList(
ListBox
)的
控件
。 扩展DropDownList
控件
和
ListBox
控件
- 支持分组功能(optgroup标签) 介绍 扩展DropDownList
控件
和
ListBox
控件
: 通过DropDownList
控件
和
ListBox
控件
的.
Items
.Add(ListItem item)方法,来为其添加optgroup标签,从而实现分组功能 可以导出Excel或Word
QQ好友列表
控件
_C#
QQ好友例表
控件
带实例和源码 //1. 属性列表: // SelectionMode 组件
中
条目的选择类型,即多选(Multiple)、单选(Single) // Rows 列表框
中
显示总共多少行 // Selected 检测条目是否被选
中
// SelectedItem 返回的类型是ListItem,获得列表框
中
被选择的条目 // Count 列表框
中
条目的总数 // SelectedIndex 列表框
中
被选择项的索引值 //
Items
泛指列表框
中
的所有项,每一项的类型都是ListItem //2. 取列表框
中
被选
中
的值 //
ListBox
.SelectedValue //3. 动态的添加列表框
中
的项: //
ListBox
.
Items
.Add("所要添加的项"); //4. 移出指定项: // //首先判断列表框
中
的项是否大于0 // If(
ListBox
.
Items
.Count > 0 ) // { ////移出选择的项 //
ListBox
.
Items
.Remove(
ListBox
.SelectedItem); // } //5. 清空所有项: // //首先判断列表框
中
的项是否大于0 // If(
ListBox
.
Items
.Count > 0 ) // { ////清空所有项 //
ListBox
.
Items
.Clear(); // } //6. 列表框可以一次选择多项: // 只需设置列表框的属性 SelectionMode="Multiple",按Ctrl可以多选 //7. 两个列表框联动,即两级联动菜单 // //判断第一个列表框
中
被选
中
的值 // switch(
ListBox
1.SelectValue) // { ////如果是"A",第二个列表框
中
就添加这些: //case "A" //
ListBox
2.
Items
.Clear(); //
ListBox
2.
Items
.Add("A1"); //
ListBox
2.
Items
.Add("A2"); //
ListBox
2.
Items
.Add("A3"); ////如果是"B",第二个列表框
中
就添加这些: //case "B" //
ListBox
2.
Items
.Clear(); //
ListBox
2.
Items
.Add("B1"); //
ListBox
2.
Items
.Add("B2"); //
ListBox
2.
Items
.Add("B3"); // } //8. 实现列表框
中
项的移位 // 即:向上移位、向下移位 // 具体的思路为:创建一个
ListBox
对象,并把要移位的项先暂放在这个对象
中
。 // 如果是向上移位,就是把当前选定项的的上一项的值赋给当前选定的项,然后 // 把刚才新加入的对象的值,再附给当前选定项的前一项。 // 具体代码为: // //定义一个变量,作移位用 // index = -1; // //将当前条目的文本以及值都保存到一个临时变量里面 // ListItem lt=new ListItem (
ListBox
.SelectedItem.Text,
ListBox
.SelectedValue); // //被选
中
的项的值等于上一条或下一条的值 //
ListBox
.
Items
[
ListBox
.SelectedIndex].Text=
ListBox
.
Items
[
ListBox
.SelectedIndex + index].Text; // //被选
中
的项的值等于上一条或下一条的值 //
ListBox
.
Items
[
ListBox
.SelectedIndex].Value=
ListBox
.
Items
[
ListBox
.SelectedIndex + index].Value; // //把被选
中
项的前一条或下一条的值用临时变量
中
的取代 //
ListBox
.
Items
[
ListBox
.SelectedIndex].Test=lt.Test; // //把被选
中
项的前一条或下一条的值用临时变量
中
的取代 //
ListBox
.
Items
[
ListBox
.SelectedIndex].Value=lt.Value; // //把鼠标指针放到移动后的那项上 //
ListBox
.
Items
[
ListBox
.SelectedIndex].Value=lt.Value; //9. 移动指针到指定位置: // (1).移至首条 // //将被选
中
项的索引设置为0就OK了 //
ListBox
.SelectIndex=0; // (2).移至尾条 // //将被选
中
项的索引设置为
ListBox
.
Items
.Count-1就OK了 //
ListBox
.SelectIndex=
ListBox
.
Items
.Count-1; // (3).上一条 // //用当前被选
中
的索引去减 1 //
ListBox
.SelectIndex=
ListBox
.SelectIndex - 1; // (4).下一条 // //用当前被选
中
的索引去加 1 //
ListBox
.SelectIndex=
ListBox
.SelectIndex + 1; //this.
ListBox
1.
Items
.Insertat(3,new ListItem("插入在第3行之后项","")); //this.
ListBox
1.
Items
.Insertat(index,ListItem) //
ListBox
1.
Items
.Insert(0,new ListItem("text","value"));
C++ Builder
13,825
社区成员
102,679
社区内容
发帖
与我相关
我的任务
C++ Builder
C++ Builder相关内容讨论区
复制链接
扫一扫
分享
社区描述
C++ Builder相关内容讨论区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章