Textbox_KeyPress事件用vb.net或C# [英] Textbox_KeyPress Event using vb.net or c#

查看:1047
本文介绍了Textbox_KeyPress事件用vb.net或C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是我试图开发我的母语语言的文本编辑器。
这就是我试图开发使用Unicode字符泰米尔文本编辑器。
,当我按键盘上的键(英文字符一样)K那个时候我想更换像两个字符&放大器; H0b95与& H0bcd。
如何我实现这个概念?是否有可能或没有。结果
样品代码时,按键事件

My requirement is i am trying to develop a text editor for my mother tongue language. That is i am trying to develop tamil text editor using unicode characters. When i am pressing key on the keyboard(English character like) k that time i want to replace two characters like "&H0b95" "&H0bcd". How to i implement this concept? whether it is possible or not.
sample code when keypress event

 e.keychar=chrw("&H0b95") & chrw("&H0bcd") 'This code is not Execute Becuase it get Only One Character'

 TextBox1.Text=chrw("&H0b95") & chrw("&H0bcd")



我已经完成这个概念,但唯一的问题是光标位置是滚动的是,当我分配给文本框的时间选择起始字符是零,因此光标到第一的位置。 2行以后我正在设置光标位置被光标来到文文末的长度。

I am already finish this concept but the only problem is cursor position is scroll that is when i am assigning the character to textbox that time selection start is zero so the cursor go to first position. after second line i am set the cursor position to the length of the text that is cursor come to end of the text.

所以问题光标上下移动当我按在各个时代的关键。如何解决这个问题。任何机构可以给一个想法给我。

so the problem is the cursor move up and down when i am pressing a key at all the times. how to solve this problem. can any body given an idea to me.

点击的这里!要见泰米尔Unicode字符表。

Click here! To See the Tamil Unicode Characters Table.

推荐答案

您需要更新SelectionStart属性,并增加新的尺寸长度文本插入。
是这样的:

You need to update the SelectionStart Property and increase its length with the size of the new text inserted. Something like:

int curPos = txtEditor.SelectionStart;
if (e.KeyChar == 'k')
{
    txtEditor.Text=txtEditor.Text.Insert(txtEditor.SelectionStart, "jj");
    txtEditor.SelectionLength = 0;
}
txtEditor.SelectionStart = curPos + 2; //or whatever the length of text u inserted    

这篇关于Textbox_KeyPress事件用vb.net或C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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