這篇文章將為大家詳細講解有關C#中怎么利用listbox實現一個雙擊事件,文章內容質量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。
讓客戶滿意是我們工作的目標,不斷超越客戶的期望值來自于我們對這個行業的熱愛。我們立志把好的技術通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領域值得信任、有價值的長期合作伙伴,公司提供的服務項目有:申請域名、虛擬空間、營銷軟件、網站建設、鋼城網站維護、網站推廣。
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 = ";
mflistboxjs += "{";
mflistboxjs += "var addOption=document.createElement('option'); \n";
mflistboxjs += "var index1; \n";
mflistboxjs += "if(RemoveListBox.length==0)return(false);\n";
mflistboxjs += "index1=RemoveListBox.selectedIndex; \n ";
mflistboxjs += "if(index1<0)return(false);\n";
mflistboxjs += "addOption.text=RemoveListBox.options(index1).text; \n";
mflistboxjs += "addOption.value=RemoveListBox.value; \n";
mflistboxjs += "AddListBox.add(addOption); \n";
mflistboxjs += "RemoveListBox.remove (index1) \n";
mflistboxjs +="}";
mflistboxjs += "
關于C#中怎么利用listbox實現一個雙擊事件就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
本文標題:C#中怎么利用listbox實現一個雙擊事件
網頁URL:http://m.newbst.com/article38/pjcgsp.html
成都網站建設公司_創新互聯,為您提供商城網站、網站維護、Google、網站收錄、網站排名、品牌網站建設
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯