0
フォーム上にマウスを置いて継承したテキストボックスコントロールを表示したいとします。しかし、テキストは表示されません。以下は私のコードです。マウスの移動時にテキストボックスを表示する方法C#
private ChartCalloutBox m_calloutbox = null;
public Form2()
{
InitializeComponent();
this.MouseMove += Form2_MouseMove;
}
void Form2_MouseMove(object sender, MouseEventArgs e)
{
if (m_calloutbox == null)
{
m_calloutbox = new ChartCalloutBox();
}
m_calloutbox.Location = e.Location;
m_calloutbox.Show();
}
internal class ChartCalloutBox : TextBox
{
public ChartCalloutBox()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.SuspendLayout();
this.Location = new System.Drawing.Point(350, 170);
this.ClientSize = new System.Drawing.Size(130, 40);
this.Size = new System.Drawing.Size(130, 40);
this.BackColor = System.Drawing.Color.Black;
this.ForeColor = System.Drawing.Color.Brown;
this.Name = "CalloutBox";
this.Text = "Callout Rect";
this.ResumeLayout(false);
//
}
}
マウスの上にテキストボックスを表示する方法については、こちらをご覧ください。テキストボックスの場所はマウスの位置に基づいて変更する必要があります。
ありがとう、 Bharathi。