如何在列表框中选择多个项目? [英] How to Select multiple items in ListBox?

查看:145
本文介绍了如何在列表框中选择多个项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建列表框.在该列表框中,我要添加诸如卡纳达语,英语,印地语,泰米尔语,泰卢固语,乌尔都语等已知语言的项目.但是在这里我只能选择一项.但是任何人都可以建议我如何选择多个项目吗?

I am creating List Box . In that list Box I am adding items like Language known that is Kannada,English,Hindi,Tamil, Telugu, Urdu. But here i can select only one item . but can any one suggest me how to select multiple items?

推荐答案

将SelectionMode属性设置为多个,例如

Set the SelectionMode property to multiple, e.g.

<asp:ListBox SelectionMode="multiple" runat="server" ID="languages">
</asp:ListBox>


aspx .:
aspx.:
<div>
    <asp:ListBox ID="ListBox1" runat="server">
        <asp:ListItem Value="One" />
        <asp:ListItem Value="Two" />
        <asp:ListItem Value="Three" />
        <asp:ListItem Value="Four" />
        <asp:ListItem Value="Five" />
    </asp:ListBox>
</div>



C#:



C#:

protected void Page_Load(object sender, EventArgs e)
{
    ListBox1.SelectionMode = ListSelectionMode.Multiple;
    for (int i = 0; i < ListBox1.Items.Count; i++)
    {
        if(i == 0 || i == 2 || i == 4)
        {
            ListBox1.Items[i].Selected = true;
        }
    }
}


参考:以编程方式选择ASP.NET列表框的多个项目 [ ^ ]

参考:
如何在ListBox:Asp.net中选择多个项目 [ ^ ]
无法从listBox中选择多个项目. [


Ref.: Programmatically Select Multiple Items of an ASP.NET ListBox[^]

Refer:
How to select multiple item in ListBox:Asp.net[^]
Cannot select multiple items from listBox.[^]


这篇关于如何在列表框中选择多个项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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