cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jbrit2020
Responsive Resident
Responsive Resident

Auto Width of any controls

So, after spending days scratching my head on how to make a label width adjustable, and extremely unhappy with the formula:

 

 

 

 

 

20*Len(Label1.Text)

 

 

 

 

That increases the size, but doesn't really match THE size of the text (the label can end up being 4 or 5 times the size of the text)

 

I started fiddling with Point conversions and came up with this formula. You don't need to change the 0.352777777778 value as that is the average point value in millimetres of font size systems:

 

 

 

 

 

Max(25,((Label1.Size+(0.35277777777778*Label1.Size))*Len(Label1.Text))-((0.35277777777778*Len(Label1.Text))*(Len(Label1.Text))))

 

 

 

 

 

Doesn't look pretty, and probably have one too many () in there, but it seems to work wonders for me as it matches NEARLY perfectly the width of the TEXT.

 

I'm just posting it here because it seems to be a common question and thought someone could make use of this or hopefully even, improve the formula to be slicker.

 

Please do test and let me know if it works for you as well.

0 REPLIES 0

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,420)