1、我发现TextBox控件有个问题,运行的时候“回车”它竟然不会失去焦点,光标还在原地......
2、Lebel控件不能重叠,在做立体标题的时候就不好用了,后面的Lebel会被前面的挡住......
3、划线的工具没有了,我原来想用线把一些控件给圈起来,也没有了......

不知在C#里有什么解决的办法?
1、我发现TextBox控件有个问题,运行的时候“回车”它竟然不会失去焦点,光标还在原地......
2、Lebel控件不能重叠,在做立体标题的时候就不好用了,后面的Lebel会被前面的挡住......
3、划线的工具没有了,我原来想用线把一些控件给圈起来,也没有了......
这样写出错!自定义:TextBox 控件让其回车自动失去焦点
public class MyTextBox:TextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
if (e.KeyChar == System.Convert.ToChar(13)) //回车
{ this.LostFocus(); } //这个地方出错,请教该怎么写,让其失去焦点?
}
}
}
谢谢楼上的,这种方法很好用!
我添加了自定义控件,代码也写了
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace yyxt
{
public partial class MyTextBox : UserControl
{
public MyTextBox()
{
InitializeComponent();
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == System.Convert.ToChar(13))
{ SendKeys.Send("{Tab}"); }
}
}
}
运行时很好用,直接回车就跑到下一个控上了!不过也发现了一些问题,运行时定义的控件邦定不好用了:
textBH.DataBindings.Add("Text", ds, "ark.idark"); //textBH是由MyTextBox拖拽而来,并把Name属性改为:textBH
WHY???怎么改?
各位老大,就差一点点了,再看一看啊:
运行时很好用,直接回车就跑到下一个控上了!不过也发现了一些问题,运行时定义的控件邦定不好用了:
textBH.DataBindings.Add("Text", ds, "ark.idark"); //textBH是由MyTextBox拖拽而来,并把Name属性改为:textBH
WHY???怎么改?