码迷,mamicode.com
首页 > Windows程序 > 详细

C#文本选中及ContextMenuStrip菜单使用

时间:2016-03-17 09:42:36      阅读:302      评论:0      收藏:0      [点我收藏+]

标签:

‘文本框选中显示
‘TextBox1.SelectAll()选择所有文本
1
Private Sub TextBox1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseClick 2 Dim start As Integer = TextBox1.SelectionStart 光标开始位置索引 3 Dim SelectValue As String = TextBox1.SelectedText 选中文本的值 4 Dim length As Integer = TextBox1.SelectedText.Trim.Length 选中文本的长度 5 If length > 0 Then 6 TextBox1.Select(start, length) 选中文本从光标到指定长度 7 End If 8 End Sub
‘选中文本后右键弹出菜单栏
1
Private Sub TextBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown 2 3 If TextBox1.SelectedText.Trim.Length > 0 Then 4 If e.Button = Windows.Forms.MouseButtons.Right Then 5 TextBox1.Enabled = False 6 TextBox1.ContextMenuStrip = ContextMenuStrip1 7 TextBox1.Enabled = True 8 End If 9 End If 10 End Sub

 

C#文本选中及ContextMenuStrip菜单使用

标签:

原文地址:http://www.cnblogs.com/slmdr9/p/5286067.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!