adding tooltip to dynamic controls [resolved]
I am adding a grid of command buttons to a user control. I am having trouble adding the tooltiptext at runtime. I have a tooltip control added to the user control form. Here is the code where I want to add it:
Code:
int x=0,y=0;
p_socks=new Button[iX,iY];
try
{
for(x=0;x<iX;x++)
{
for(y=0;y<iY;y++)
{
//set socket's back color to default backcolor;
//p_sockColor[x,y]=p_defaultColor;
//no need to create sockets again
if(socketsCreated)
return true;
//generate socket name
string butName=x.ToString()+(char)(y+'A');
//add new buttons
p_socks[x,y]=new Button();
this.Controls.Add(p_socks[x,y]);
p_socks[x,y].Location = new System.Drawing.Point(10, 10);
p_socks[x,y].Name = "butX"+x+"Y"+y;
p_socks[x,y].Size = new System.Drawing.Size(20, 20);
p_socks[x,y].TabIndex = 20;
p_socks[x,y].Click+=new System.EventHandler(sockClickHand);
//p_socks[x,y].tooltip????????????????
}
}
this.Refresh();
return true;
}
thx
Re: adding tooltip to dynamic controls
You can't set the tooltip using some control property, you'll have to add a tooltip component to your usercontrol and call ToolTip1.SetToolTip(AndSoOn) for each of your buttons.
Greetings
Re: adding tooltip to dynamic controls
Great, thx. It worked.
Here is what the solution looks like:
Code:
for(x=0;x<p_xSockets;x++)
for(y=0;y<p_ySockets;y++)
toolTip1.SetToolTip(p_socks[x,y],p_sockRouting[x,y]);
Re: adding tooltip to dynamic controls [resolved]
That's right, now rep me you.... ;)