Include text in a ProgressBar

1

I am trying to include a text in a ProgressBar (which I have modified to be in vertical mode) so that I will update it when I change the value, I have tried trying to write the text HELLO but it does not include it in any way , the code is as follows:

    Dim gr As Graphics
    gr = Me.MyVerticalProgessBar1.CreateGraphics()
    gr.DrawString("HOLA",
    SystemFonts.DefaultFont,
    Brushes.Black,
    New PointF(Me.MyVerticalProgessBar1.Width / 2 - MeasureString("HOLA",
    SystemFonts.DefaultFont).Width / 2.0F),
    Me.MyVerticalProgessBar1.Height / 2 - (gr.MeasureString("HOLA",
    SystemFonts.DefaultFont).Height / 2.0F)))

I include a screenshot to see that it does not appear:

    
asked by marcss 27.09.2018 в 10:15
source

1 answer

1

You have the final position of the controls wrong, this code will solve it ...

Dim gr As Graphics
    gr = Me.MyVerticalProgessBar1.CreateGraphics()
    gr.DrawString("HOLA",
    SystemFonts.DefaultFont,
    Brushes.Black,
    New PointF((Me.MyVerticalProgessBar1.Width / 2) - (MeasureString("HOLA",
    SystemFonts.DefaultFont).Width / 2)),
    (Me.MyVerticalProgessBar1.Height / 2) - (gr.MeasureString("HOLA",
    SystemFonts.DefaultFont).Height / 2)))
    
answered by 05.11.2018 / 17:45
source