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被添加为表单的控件。
答案 0 :(得分:4)
您必须将该文本框添加到txtBoxDragPoint.Show()
form
this.Controls.Add(txtBoxDragPoint);
答案 1 :(得分:2)
您必须将文本框添加到表单
this.Controls.Add(txtBoxDragPoint );
txtBoxDragPoint .BringToFront();