|
-
May 14th, 2021, 01:50 AM
#1
Thread Starter
New Member
Unexpected Label Width Size
Background Info: I'm building an app which I keep expanding. The point of it all, is to view pictures stored into Album directories. It's for a Music Collection, whereas:
- File Structure: D:\Music\Artist\Album
- Each album folder has a collection of 6 pictures.
- The app will have 7 tab pages within a tab control
- The First Tab will view all images of an individual album
- Each of the six remaining tabs will display the specific image from each Album folder, each with a label on top, and on bottom (Artist Label / PictureBox / Album Label)
- With 1,200 CDs, that's 1,200 images per tab. There will be some dynamic movement going on (print first, move to the right, print the second...until I have to go to the next line, so on and so forth...)
- With 7,200 images to load, I will have to figure something out so it doesn't crash on me, I don't think I'm there yet.
Anyways, I'm currently working with one tab where I'm displaying a PictureBox (pboIMG) at a specific starting location. Using the X,Y Positions of the PictureBox and the Height/Width, I'm setting a starting location of a label, above it. I'll be doing the same thing below it, as well. For now, the top label is called lblArtist, which I'm having trouble with. When I draw a control at Design time, the height is ALWAYS 25, it just does it by default, based on the font name and font size, I believe. I always have AutoSize set to True. However, at runtime, when drawing a label box, both height and width are off.
Here's my code:
Code:
Dim lblArtist As New Label
With lblArtist
.Text = "asdfasdfasdfsfadf"
.Font = New Font("Segoe UI", 14.25, FontStyle.Regular)
.AutoSize = True
.Location = New Point(pboIMG.Location.X + ((pboIMG.Width - lblArtist.Width) / 2), (pboIMG.Location.Y - 5 - lblArtist.Height))
End With
I have isolated the issue, but I do not know how to fix it. Basically, it looks like the AutoSize is not working correctly on the lblArtist Label Control, for neither Height or Width.
To test:
- I Copied/Pasted existing labels from my first tab, which were also set to AutoSize = True.
- First Label Control: The Text "Cover.jpg" produced a size of (Height) 92, (Width) 25.
- Copied Label Control: The Text "asdfasdfasdfsfadf" produced a size of 158, (Width) 25.
- In fact, every time I use the ToolBox to draw a new label, the Height defaults to 25.
- When drawing a label box at runtime with the text "asdfasdfasdfsfadf", it produces the size of (Width) 100, (Width) 23, when it should be 158, 25 as in my Copy/Paste test.
- For my pasted label control, I manually set the width to 100, which forced the text to cut off. This was expected.
- For the controls drawn, AutoSize = True in Properties. For the runtime control, .AutoSize = True is used in an Width/End With statement, as you can see in my code.
- I have checked every other input I will be using in the formula to calculate the starting position, they are all correct.
Question: Why is the size of the label control which is drawn at runtime, not working as expected and how can I fix this? Is there another property that I need to set that I'm missing?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|