如何在自定义的控件中使用输入法
2008-03-20 16:04
197 查看
1.需要将Control.ImeMode设置为On
2.处理OnKeyPress
public class EditorControl : System.Windows.Forms.Control
{
public EditorControl()
{
//开启输入法模式
this.ImeMode = System.Windows.Forms.ImeMode.On;
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
base.OnPaint(e);
//将Text显示出来
System.Windows.Forms.TextRenderer.DrawText(e.Graphics,
this.Text,
new System.Drawing.Font("微软雅黑",30),
new System.Drawing.Point(0,0),
System.Drawing.Color.Black);
}
protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)
{
base.OnKeyPress(e);
this.Text += e.KeyChar;
this.Invalidate();
e.Handled = true;//注意这里,如果这里没设置,输入中文会重复。
}
}
2.处理OnKeyPress
public class EditorControl : System.Windows.Forms.Control
{
public EditorControl()
{
//开启输入法模式
this.ImeMode = System.Windows.Forms.ImeMode.On;
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
base.OnPaint(e);
//将Text显示出来
System.Windows.Forms.TextRenderer.DrawText(e.Graphics,
this.Text,
new System.Drawing.Font("微软雅黑",30),
new System.Drawing.Point(0,0),
System.Drawing.Color.Black);
}
protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)
{
base.OnKeyPress(e);
this.Text += e.KeyChar;
this.Invalidate();
e.Handled = true;//注意这里,如果这里没设置,输入中文会重复。
}
}
相关文章推荐
- 如何:使用自定义函数对 ASP.NET 服务器控件进行验证
- MFC总结(4)---MFC中如何使用子控件向父控件发送自定义消息
- Android使用属性动画如何自定义倒计时控件详解
- ASP.NET - 如何:使用自定义函数对 ASP.NET 服务器控件进行验证
- 如何在aspx页面中使用ascx控件(用户自定义的一个控件)?
- 如何在VC中使用自定义的SkinMagic控件?
- 图形的绘制,如何使用自定义画笔(颜色,线宽,线形)。如何为程序中添加选项菜单和选项设置对话框,如何使用标准颜色对话框,如何使用字体对话框,在选项对话框中实现预览功能。实现选项对话框和窗口类中的数据交换。如何改变对话框和控件的背景色,如何改变控件的文本颜色,
- 如何自定义布局文件中,控件对数据源中对数据的使用方式
- Swift技术之如何在iOS 8下使用Swift设计一个自定义的输入法 (主要是NSLayoutConstraint 的使用)
- Flex中如何通过设置fontFamily样式在ComboBox控件中使用自定义嵌入字体的例子
- xib自定义的控件如何在xib中使用
- 【ios】论自定义的控件如何在xib中使用,自定义控件在xib中的初始化入口函数
- 如何在styles.xml中使用控件自定义属性
- 如何在aspx页面中使用ascx控件(用户自定义的一个控件)?
- C#如何创建自定义控件以及添加自定义属性和事件使用
- 论自定义的控件如何在xib中使用,自定义控件在xib中的初始化入口函数
- 如何:使用自定义函数对 ASP.NET 服务器控件进行验证
- 如何在aspx网页中使用.net编译后的自定义用户控件
- 如何在ASP.NET中制作Web用户自定义控件,并在aspx页面中使用它的方法和属性?
- Android如何实现自定义控件