How to change label control dynamically
in my project i'm having multiple label controls i want to change the label controls dynamically how it is possible in code
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


Ravi Polara PatidarRank #2,471 · 568 reputationPosted Feb 2, 2017, 11:37 PM EST
The problem is that
Control.Locationgives your position within the current container. You just need to get the absolute location of the control with respect to the form like this:void ShowCustomToolTip(string text, Control targetControl, int duration = 1000, int x = 0, int y = 0) { customToolTip.Text = text; customToolTip.Visible = true; Point absoluteLocation = targetControl.FindForm().PointToClient( targetcontrol.Parent.PointToScreen(control.Location)); // the crucial line that needs to be changed, I guess customToolTip.Location = new Point(absoluteLocation.X + x, absoluteLocation.Y + y); Set.Timer(duration); customToolTip.Hide(); }