Vinícius Gabriel Vinícius Gabriel - 10 months ago 61
C# Question

Label Position Based of the form in c#

I have a project of a Calendar. The main form, where I show a column with time of the day (00:00 \n 00:30 \n 01:00 \n ...), so it's needs to have a scroll bar.
The problem is that I want a line(Label) to represent the current time of the day, and when I set the location of the line in the form using

LFollowTime.Location = new Point(61,Convert.ToInt32(a));

its location is set based on the position of the screen and not based of the form, where I want.
It means that every time a scroll the form, the position of the label is the same, and all the rest slides.

Answer Source

I guess you are working on the windows Form application. If I am true you need to set the Dock property of the label or Otherwise try this.

public Form1()
      this.AutoScroll = true;
and then this.
LFollowTime.Location = new Point(0 + this.AutoScrollPosition.X, 0 + this.AutoScrollPosition.Y);