に設定されていtab-control
ます。マウスが特定の場所に移動したときに、その場所の色を変更する必要があります。使用してみましたが、の色を変更する方法に行き詰まっています。DrawMode
OwnerDrawFixed
tab-control
Rectangle
Rectangle
これは私が持っているものです。
private void tabControl1_MouseMove(object sender, MouseEventArgs e)
{
for (int i = 0; i < this.tabControl1.TabPages.Count; i++)
{
Rectangle r = tabControl1.GetTabRect(i);
Rectangle closeButton = new Rectangle(r.Right - 15, r.Top + 4, 12, 12);
if (closeButton.Contains(e.Location))
{
}
}
}
編集: DrawItem
コード
private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
{
e.Graphics.DrawString("x", e.Font, Brushes.Red, e.Bounds.Right-16, e.Bounds.Top+4);
e.Graphics.DrawString(this.tabControl1.TabPages[e.Index].Text, e.Font, Brushes.Black, e.Bounds.Left + 12, e.Bounds.Top + 4);
e.DrawFocusRectangle();
}
私の質問は、長方形にどのように色を付けるか、それが不可能な場合は、他にどのような方法を使用できますか?.