一个ListBox1控件,DoubleClick的代码是:If e.Form.Controls("TextBox1").Value = Nothing Then Dim lst As WinForm.ListBox = e.Form.Controls("ListBox1") If lst.SelectedIndex >=0 Then Dim s As String = lst.SelectedItem e.Form.Controls("用户名").Text = s.Remove(s.IndexOf("(")) '删除"("之后的字符 End If Else Dim lst As WinForm.ListBox = e.Form.Controls("ListBox1") If lst.SelectedIndex >=0 Then Dim s As String = lst.SelectedItem If s.Remove(s.IndexOf("(")) <> e.Form.Controls("用户名").Text Then If MessageBox.Show("您确定要清空聊天记录吗?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes Then e.Form.Controls("TextBox1").Value = Nothing e.Form.Controls("TextBox3").Value = Nothing e.Form.Controls("用户名").Text = s.Remove(s.IndexOf("(")) '删除"("之后的字符 Else e.Form.Controls("用户名").Text = s.Remove(s.IndexOf("(")) '删除"("之后的字符 是我加上去的,在示例里运行没有影响 End If End If End If End If
|