如何使用按钮在文本框中添加和插入文本
问题描述:
我正在为我的项目编程一个虚拟键盘.在按钮A上,我写的代码为
Hi,
I am programming a virtual keyboard for my project. On a button A, i written a code as
Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btna.Click
txtpatname.Text = txtpatname.Text.Insert(txtpatname.SelectionStart, "a")
End Sub
使用此代码,每次我必须选择文本框然后单击按钮A时(即不附加按钮),它将直接在文本框的开头显示光标.
任何帮助将不胜感激.
在此先谢谢您.
With this code, everytime I have to select textbox and then click on Button A i.e it not appending, it is showing cursor directly at start of the textbox.
Any help will be kindly appreciated.
Thanks in advance.
答
您好,请尝试以下操作:
Hi, try this:
Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btna.Click
txtpatname.Text = txtpatname.Text + "a"
End Sub