将控件的 AutoPostBack属性设置为true,然后在SelectedIndexChanged事件中,判断具体选择的是什么事件,再做具体的操作
//HTML代码
<asp:ListBox id="ListBox1" style="Z-INDEX: 104; LEFT: 224px; POSITION: absolute; TOP: 216px"
runat="server" Width="184px" AutoPostBack="True">
<asp:ListItem Value="34324">34324</asp:ListItem>
<asp:ListItem Value="2344">2344</asp:ListItem>
<asp:ListItem></asp:ListItem>
</asp:ListBox>//响应事件
private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(ListBox2.SelectedIndex>-1)
this.Label1.Text=ListBox1.SelectedValue.ToString(); }
//HTML代码
<asp:ListBox id="ListBox1" style="Z-INDEX: 104; LEFT: 224px; POSITION: absolute; TOP: 216px"
runat="server" Width="184px" AutoPostBack="True">
<asp:ListItem Value="34324">34324</asp:ListItem>
<asp:ListItem Value="2344">2344</asp:ListItem>
<asp:ListItem></asp:ListItem>
</asp:ListBox>//响应事件
private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(ListBox2.SelectedIndex>-1)
this.Label1.Text=ListBox1.SelectedValue.ToString(); }
这还用你说呀是双击时才发生的
而且是双击一个Item时
不是双击这个控件的任何部分
winForm下的
{
MessageBox.Show(listBox1.SelectedItem.ToString());
}
MouseEnter
MouseMove
MouseLeave
MouseHover
MouseDown
SelectedValueChanged
SelectedIndexChanged
MouseUp
DoubleClick
可以你要用的是 DoubleClick事件
private void listBox1_DoubleClick(object sender, System.EventArgs e)
{
string obj=sender.ToString();
}
可以取出双击的那一个项
{
MessageBox.Show(listBox1.Items[listBox1.SelectedIndex].ToString());
}
请问是什么原因?
请问是什么原因?