I got a few labels which show a entire week.
It's displaying the long date like this

LblCurrentDay.Text = Date.Now().ToString("D")
LblCurrentDay1.Text = Date.Now().AddDays(1).ToString("D")
LblCurrentDay2.Text = Date.Now().AddDays(2).ToString("D")
LblCurrentDay3.Text = Date.Now().AddDays(3).ToString("D")
LblCurrentDay4.Text = Date.Now().AddDays(4).ToString("D")
LblCurrentDay5.Text = Date.Now().AddDays(5).ToString("D")
LblCurrentDay6.Text = Date.Now().AddDays(6).ToString("D")

The labels are all inside each of their own small panel.
But since not all days day got the same length, sometimes it will be not centered.
Sometimes even partialy outside the panel and not visible.

So i would have to center them according to their size i guess.

To calculate the new position of the label, subtract half the width of the label from half the width of the panel as in

Label1.Location = New Point(Panel1.Width / 2 - Label1.Width / 2, Label1.Location.Y)

By default, labels are set to autosize so if you do this calculation when the text changes then the label should stay centered.

Works perfect, thanks a lot Rev Jim

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.