我有一个带有工具提示的单选按钮。但是我想让用户立即认识到这里有一个工具提示。我听说过一些程序在圆周内使用黄色问号。在c#上也存在相同的情况吗?
发布于 2014-09-01 12:11:48
你可以试试这样的东西:
public void adornQM(Control ctl)
{
Label QM = new Label();
QM.Text = "?";
QM.Font = new Font("Arial", 6f, FontStyle.Regular);
QM.BackColor = Color.Yellow;
QM.Location = new Point(ctl.Width - 8, 0);
ctl.Controls.Add(QM);
}
像这样使用它:
adornQM(checkBox1);
adornQM(radioButton1);
它向控件的Controls集合添加一个标签。如果控件的文本有一两个拖尾空白,则效果最好。
只要付出一点额外的努力,你就可以或多或少地通过所有者绘图来扭转它。
public void adornQM(Control ctl)
{
Label QM = new Label();
QM.Font = new Font("Arial", 7f, FontStyle.Regular);
QM.Location = new Point(ctl.Width - 13, 0);
QM.Paint += QM_Paint;
ctl.Controls.Add(QM);
}
void QM_Paint(object sender, PaintEventArgs e)
{
Label QM = sender as Label;
e.Graphics.FillEllipse(Brushes.Yellow, 0, 0, 12, 12);
e.Graphics.DrawEllipse(Pens.DarkSlateBlue, 0, 0, 12, 12);
e.Graphics.DrawString("?", QM.Font, Brushes.Black, 2, 1);
}
这两个版本将添加一个额外的控件,为每个控件您所装饰。相反,您可以自己绘制所有控件,但是看起来更多的工作。
https://stackoverflow.com/questions/25604997
复制相似问题