private TextBox txtBoxDragPoint = new TextBox();
private void rtbLogicCode_MouseDown(object sender, MouseEventArgs e)
{
if (dragInfo.Item2 == true)
{
//MessageBox.Show("Works");
Point p = new Point(e.X, e.Y);
txtBoxDragPoint.Name = dragInfo.Item1;
txtBoxDragPoint.Text = dragInfo.Item1;
txtBoxDragPoint.Location = p;
txtBoxDragPoint.Size = new Size(100, 21);
txtBoxDragPoint.Show();
}
}
我有一个文本框,应该在用户单击 RichTextBox 时显示。事件和布尔条件很好,因为它显示了消息框,但是它没有显示文本框本身。我还有其他事情要做吗?
编辑:正如回复中提到的,我做了以下附录,但文本框仍然没有显示:
txtBoxDragPoint.Name = dragInfo.Item1;
txtBoxDragPoint.Text = dragInfo.Item1;
txtBoxDragPoint.Location = p;
txtBoxDragPoint.Size = new Size(100, 21);
this.Controls.Add(txtBoxDragPoint);
txtBoxDragPoint.Show();
我不知道此信息是否相关,但 RTB 被添加为 tabcontrol 的控件,而 tabcontrol 被添加为表单的控件。