列表框再次出现问题 [英] Again some problem with Listbox

查看:61
本文介绍了列表框再次出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮忙?
我有一个带有一些名称的列表框(数据源在代码中分配)

listbox1
格里
汤姆
鲍勃
艾丽莎
麦当娜
德雷尼
梅尼
Geni

因此,当我单击一个仅向我显示列表框中前四个成员的按钮时,如何使用其他列表或用于示例...该列表也应类似于MessaggeBox

因此,在消息框或另一个仅是前四个成员的列表框中,例如:
格里
汤姆
鲍勃
艾丽莎


thnx

who can help please?
I have a listbox with some names (datasource is assigned in code)

listbox1
Gery
Tom
Bob
Alisa
Madona
Dreni
Meni
Geni

so how can i use another list or for exampl when I clik in a button that show me only first four members in listbox... that list should be also like MessaggeBox

so in messagge box or another listbox that be only the first four member like:
Gery
Tom
Bob
Alisa


thnx

推荐答案

尝试一下:
try this :
string msg = string.Empty;
for(int i=0;i<4;i++)
{
    msg+=(string)listbox1.Items[i] + "\n";
}
MessageBox.Show("The first four items :\n" + msg);


这篇关于列表框再次出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆