使用左右按钮移动文本光标 [英] move the text cursor using right and left button

查看:76
本文介绍了使用左右按钮移动文本光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能帮我吗?

我的程序不完整.我做了一个虚拟键盘,但左右按钮不起作用.

计划是每次单击左键或右键都会移动文本光标.

任何帮助将不胜感激.

谢谢.

Can you please help me.

I have a program which is incomplete. I made a virtual keyboard but the left and right button is not working.

The plan was that every time the left or right button was clicked the text cursor also would move.

Any help is greatly appreciated.

Thanks.

推荐答案

也许您可以尝试使用TextBox.SelectionStart属性.
Maybe you can try the TextBox.SelectionStart Property.
void Left_Button_Click()
{
    if(myTextBox.SelectionStart > 0)
        myTextBox.SelectionStart--;
}


void Right_Button_Click()
{
    if(myTextBox.SelectionStart < myTextBox.Text.Length)
        myTextBox.SelectionStart++;
}



http://msdn.microsoft.com/en-us/library/system.windows.controls.textbox.selectionstart.aspx [ ^ ]



http://msdn.microsoft.com/en-us/library/system.windows.controls.textbox.selectionstart.aspx[^]


这篇关于使用左右按钮移动文本光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆