<div class="codetitle"> <span><a style="CURSOR: pointer" data="49836" class="copybut" id="copybut49836" onclick="doCopy('code49836')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code49836"> <br><!--建立一個JS呼叫button的click事件--> <br><script type="text/javascript"> <BR>function JsListChangeItem() { <br><br>document.getElementById("buttonShow").click(); <BR>} <BR></script> <br><!--建立一個隱藏的button,建立雙擊事件---> <br><button id="buttonShow" runat="server" onclick="buttonShow_Click" text="Button" style="display:none"></button> <br><br><!--實作雙擊的listbox--> <br><listbox id="listBox1" runat="server" height="226px" width="211px " autopostback="True"></listbox> <br> </div> <br>.cs <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="41550" class="copybut" id="copybut41550" onclick="doCopy('code41550')"><u>複製代碼</u></a></span>程式碼如下:</div> <div class="codebody" id="code41550"> <br>protected void Page_Load(object sender, EventArgs e) <br>{ <br>listBox1.Attributes.Add("ondblclick", "JsListChangeItem()");//butes.Add("ondblclick", "JsListChangeItem()"新增雙擊事件。 <br>} <br> </div>