Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Label exactly that width of his text...

Posted on 2004-10-24
2
Medium Priority
?
264 Views
Last Modified: 2010-05-18
Hi

I have a problem. I several labels which I can move and they have a transparent background

Now I can edit the text of the label.

So my question: How can I make the label exact that width that it is showing the text and not more? Otherwise I have problems if I place two labels aside of each others...

The Problem is that 'i' takes a half a size then 'B' and so on...

Any solutions?

Thanks a lot

Sven
0
Comment
Question by:Svenrutten
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 220 total points
ID: 12393649
Something like this may work:

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Label2.Text = TextBox1.Text
        Dim g As Graphics = Label2.CreateGraphics
        Label2.Width = g.MeasureString(Label2.Text, Label2.Font).Width + 1 ' (a little flub)
        g.Dispose()
    End Sub

~IM
0
 

Author Comment

by:Svenrutten
ID: 12393667
That's great!! Didn't think that this would be possible!

Thanks so much!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question