当前位置:编程学习 > C#/ASP.NET >>

用数组绑定listbox,如何默认全部选中啊?


string typename ="广州/上海/北京";
string[] sarray=typename.Split('/');
foreach(string i in sarray)
this.listbox.DataSource=sarray;
this.listbox.DataBind();
我用这段代码绑定listbox,数据是绑进去了,但不不是选中的状态,如果修改能让listbox里面的数据默认全部选中呢?? --------------------编程问答-------------------- 改用checkedListBox控件
--------------------编程问答--------------------             //确认listbox的选择模式为多行,遍历选中listbox的所有行                     
            this.listbox.DataSource = sarray;
            this.listbox.DataBind();
            listbox.SelectionMode = SelectionMode.MultiExtended;
            for (int i = 0; i < listbox.Items.Count; i++)
            {
                listbox.SetSelected(i, true);
            }
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,