[英]add tooltips to programmatically created controls
I have a bunch of buttons created on a winforms c# app. 我在winforms c#app上创建了一堆按钮。 I have created them using the following code
我使用以下代码创建了它们
int s = 0;//28 buttons
ButtonNameArray barray = new ButtonNameArray();
frontPanelButtons fpb = new frontPanelButtons();
int xLoc = fpb.xLoc(fpb);
int yLoc = fpb.yLoc(fpb);
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < 4; j++)
{
Button btn = new Button();
btn.Name = barray.getName(btn.Name, s);
btn.Text = barray.getText(btn.Text, s);
btn.Width = fpb.btnWide(fpb);
btn.Height = fpb.btnHigh(fpb);
btn.Location = new System.Drawing.Point(xLoc, yLoc);
Controls.Add(btn);
xLoc += 100;
s++;
}
yLoc += 31;
xLoc = fpb.xLoc(fpb);
}
And I would like to add a unique tooltip to each button but can't figure out how to do it. 我想为每个按钮添加一个独特的工具提示,但无法弄清楚如何做到这一点。 Could anyone please supply help/the answer?
有人可以提供帮助/答案吗? Many thanks.
非常感谢。
//...
ToolTip ttip = new ToolTip();
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 4; j++) {
Button btn = new Button();
// ...
ttip.SetToolTip(btn, "Some text on my tooltip.");
}
}
//...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.