none
How do you add text or string inside a progress bar?

    Question

  • How do you get text inside a progress bar or a string? Just looking for simple solution if possiable. thanks in advance.
    Monday, September 17, 2012 10:18 PM

Answers

All replies

  • Tuesday, September 18, 2012 3:11 AM
    Moderator
  • Hi old_School,

    Welcome to the MSDN forum.

    The solution for this is to draw a string into the center of process bar. Here are some samples:

    Add the Percent (or Any Text) into a Standard Progress Bar Control: http://www.codeproject.com/Articles/31406/Add-the-Percent-or-Any-Text-into-a-Standard-Progre

    Custom Control for Text Over a Progress Bar: http://www.codeproject.com/Articles/32404/Custom-Control-for-Text-Over-a-Progress-Bar

    Hope this helps.



    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, September 18, 2012 3:39 AM
    Moderator
  • thanks Mark,

    Dim percent As Int32 
    Dim gr As Graphics 'Declare these in Global Area
    
    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            Me.ProgBar1.PerformStep()
    
            percent = CInt(Me.ProgBar1.Value)
            With gr
                gr = ProgBar1.CreateGraphics
    
                gr.DrawString(percent & "%", Me.Font, Brushes.Black, _
                              Me.ProgBar1.Width / 2 - (gr.MeasureString(percent & "%", SystemFonts.DefaultFont).Width / 2.0F), _
                              Me.ProgBar1.Height / 2 - (gr.MeasureString(percent & "%", SystemFonts.DefaultFont).Height / 2.0F))
            End With
    
            If Me.ProgBar1.Value = 100 Then
                Timer1.Stop()
                MsgBox(Me.ProgBar1.Name & " progress completed")
            End If
    End Sub

    it really helps me & i was looking for this type of thread.


    Pl. Mark/Proposed as Answer if found your solution Vote as Helpful if related to your topic. Always Motivate others by performing this Action.

    • Edited by ArifMustafa Tuesday, September 18, 2012 6:42 AM
    Tuesday, September 18, 2012 6:18 AM
  • Were your issue ends?

    Pl. Mark/Proposed as Answer if found your solution Vote as Helpful if related to your topic. Always Motivate others by performing this Action.

    Tuesday, September 25, 2012 4:45 AM
  • Hi old_School,

    We haven’t heard from you for several days. I’d like to mark the helpful replies as answer firstly. If you have any additional questions, you also can unmark the replay and post your question here. 

    Sorry for any inconvenience and have a nice day.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, September 27, 2012 7:59 AM
    Moderator