可以用多個label來截取文本,然后把一個空的文本框放到中間去。
10多年的都蘭網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。全網(wǎng)整合營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整都蘭建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。創(chuàng)新互聯(lián)從事“都蘭網(wǎng)站設(shè)計”,“都蘭網(wǎng)站推廣”以來,每個客戶項目都認(rèn)真落實執(zhí)行。
文本框有 表示選擇開始。長度的屬性,
好像是 selStart 和selTextLength,這兩個屬性都是可讀寫的
再結(jié)合字符串查找函數(shù)就可以做到了。
////////
給點分啊,我?guī)湍銓懥薧_^
vs2005 +vb.net 測試通過,
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = "我愛編程-百度知道"
End Sub
Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click
Dim curindex As Integer = TextBox1.SelectionStart
Dim ganindex As Integer = TextBox1.Text.IndexOf("-")
If curindex ganindex Then
TextBox1.SelectionStart = 0
TextBox1.SelectionLength = ganindex
Else
TextBox1.SelectionStart = ganindex + 1
TextBox1.SelectionLength = TextBox1.Text.Length - ganindex
End If
End Sub
End Class
如果是6.0 的話,可能屬性名字有點變化,indexof函數(shù)可以使用
mid或者 instr函數(shù)來代替
(1)失去焦點,拖一個文本框到頁面上,選擇該文本框,查看一下該文本框的事件,里面應(yīng)該有文本框的焦點事件,自己查查看。
(2)如果是winform的話在控件的屬性里應(yīng)該有坐標(biāo)的屬性項可以填寫。web的話需要html的布局來確定該文本框的位置。
假如Form1有個TextBox1,雙擊TextBox1填入123
Public Class Form1
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.DoubleClick
System.Windows.Forms.SendKeys.Send("123")
End Sub
End Class
看你的VB.NET 版本了
用 My.Computer.Keyboard.SendKeys("123", True) 代替 System.Windows.Forms.SendKeys.Send("123") 也可以
原碼:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.DoubleClick
My.Computer.Keyboard.SendKeys("123", True)
End Sub
End Class
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
TextBox1.SelectionStart = Len(TextBox1.Text)
End Sub