正在加载图片...
当 ListBo控件允许多选时,要通过循环来依次判断哪些选项被选中。 事件过程代码如下 a protected void Button1_Click(object sender, EventArgs e Label1text="你选中的选项为:"; for (int 1=0;i< Listbox1 Items. Count;i++)/取列表选项总数 Items. Count if ListBox Items. Selected) //如果本选项 被选中 Labell.Text + ListBox1. Items. Value+ 要选中多项,按下Ctrl键操作鼠标可选中不连续的多项,按下 Shift键 操作鼠标可选中连续的多项。◼ 当ListBox控件允许多选时,要通过循环来依次判断哪些选项被选中。 事件过程代码如下: ◼ protected void Button1_Click(object sender, EventArgs e) ◼ { ◼ Label1.Text = "你选中的选项为:"; ◼ for (int i = 0; i < ListBox1.Items.Count; i++) //获取列表选项总数 .Items.Count ◼ { ◼ if (ListBox1.Items[i].Selected) //如果本选项 被选中 ◼ { ◼ Label1.Text += ListBox1.Items[i].Value + " "; ◼ } ◼ } ◼ } ◼ 要选中多项,按下Ctrl键操作鼠标可选中不连续的多项,按下Shift键 操作鼠标可选中连续的多项
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有