如果创建一个字典程序。当使用在剪贴板上复制一些文本时,它将以系统尝试可见的形式给出复制文本的含义。当用户单击他/她屏幕上的任何位置时,我想关闭表单。但是如果用户想从不关闭的含义中复制一些文本,我会在选项卡控件中添加一个动态创建的丰富文本框以显示含义的数量。当用户滚动richtextboxes 表单时,我的代码运行良好,接受一件事会自行关闭。滚动条似乎不是richtextbox的一部分。帮我解决这个问题,我的代码如下。
Dim s As Boolean = True
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If MouseButtons.ToString = "Left" Or MouseButtons.ToString = "Right" Then
If s = True Then
If InStr(LCase(Me.ActiveControl.ToString), LCase("Label")) Then
Me.Close()
End If
End If
End If
End Sub
Private Sub Label1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Label1.Click
Me.Close()
End Sub
Private Sub frmdict_MouseEnter(ByVal sender As Object, ByVal e As EventArgs) Handles Me.MouseEnter
s = False
Button1.Focus()
End Sub
Private Sub frmdict_MouseLeave(ByVal sender As Object, ByVal e As EventArgs) Handles Me.MouseLeave
s = True
Label1.Focus()
End Sub
==更新==
我有 form1,其中包含此代码以将richtextboxes 和选项卡添加到 tabcontrl
Dim myTabPage As New TabPage()
Dim myrichtext As New RichTextBox()
myrichtext.Name = "RichTextBox" & i
myTabPage.Text = StrSearch & i
frmdict.TabControl1.TabPages.Add(myTabPage)
myTabPage.Controls.Add(myrichtext)
myrichtext.RightToLeft = Windows.Forms.RightToLeft.No
myrichtext.Dock = DockStyle.Fill
myrichtext.Font = New Font("Urdulink", 14)
最后打开frmdict来表示意思
If frmdict.TabControl1.TabPages.Count > 0 Then
frmdict.TabControl1.RightToLeftLayout = True
frmdict.Show()
frmdict.Label1.Focus()
' frmdict.TabControl1.Focus()
Else
frmdict.Close()
End If