- private void Page_Load(object sender, System.EventArgs e) {
- if(!IsPostBack)
- {
- }
- if(!Page.IsStartupScriptRegistered("listbox1")) {
- ListBox_DblClick("listbox1",Page,ListBox1,"ListBox1","ListBox2"); }
- if(!Page.IsStartupScriptRegistered("listbox2")) {
- ListBox_DblClick("listbox2",Page,ListBox2,"ListBox2","ListBox1"); }
- }
下面是另一段代码,这是实现C# listbox双击的关键部分,好仔细研究哦!
- public void ListBox_DblClick(string Key,Page page,System.Web.UI.WebControls.WebControl webcontrol,
string RemoveListBox,string AddListBox)- {
- RemoveListBox = "document.Form1." + RemoveListBox;
- AddListBox = "document.Form1." + AddListBox;
- string mflistboxjs = "";
- page.RegisterStartupScript(Key,mflistboxjs);
- webcontrol.Attributes.Add("onDblClick","change(" + RemoveListBox + "," + AddListBox + ");");
- }