嘗試使用用戶控件創建自己的文本框中。這裏是一個樣本,將讓你開始:
public partial class UserControl1 : UserControl
{
private string text;
public string Text
{
get { return textBox.Text; }
set { textBox.Text = value; }
}
TextBox textBox = new TextBox();
public UserControl1()
{
InitializeComponent();
this.Paint += new PaintEventHandler(UserControl1_Paint);
this.Resize += new EventHandler(UserControl1_Resize);
textBox.Multiline = true;
textBox.BorderStyle = BorderStyle.None;
this.Controls.Add(textBox);
}
private void UserControl1_Resize(object sender, EventArgs e)
{
textBox.Size = new Size(this.Width - 3, this.Height - 2);
textBox.Location = new Point(2, 1);
}
private void UserControl1_Paint(object sender, PaintEventArgs e)
{
ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, Color.Red, ButtonBorderStyle.Solid);
}
}
在重複的問題,[這篇文章](http://stackoverflow.com/a/39420512/3110834)是你在找什麼。奇怪的是,4票的接受答案完全是誤導! –