开发者

add tooltips to programmatically created controls

I have a bunch of buttons created on a 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.");
    }
}
//...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜