How can I get label text width and height ?

sharon glipman 441 Reputation points
2021-10-11T15:48:31.423+00:00

For example if the text if label1 is "Hello World"

Than I want the get the location of the middle of the label depending on the text inside so in this case the middle should be the space between Hello and World
This way I want to set the label location by finding the middle this will be the label center location.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,919 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,229 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 119.2K Reputation points
    2021-10-11T15:57:54.553+00:00

    Try setting the AutoSize property of the label to True, set the text, then use Width, Height or Size properties.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.