![]() |
Click here to advertise with us
|
|
|||||||
| Using Components/Controls Discussion about server controls and related components for ASP.NET development |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Can anyone tell me how to put text inside a progressbar? For example, I want to embed the current percentage value of the progressbar within it. Thanks in advance! |
|
||||
|
OK here we go ... make a new project selecting a "windows control library" from templates.
Then draw a progress bar from the toolbar pane and just join next code in design view (just after 'Windows Form Designer generated code') Code:
Property Value() As Integer
Get
Return ProgressBar1.Value
End Get
Set(ByVal Value As Integer)
ProgressBar1.Value = Value
UpdateLabel()
End Set
End Property
Property Maximum() As Integer
Get
Return ProgressBar1.Maximum
End Get
Set(ByVal Value As Integer)
ProgressBar1.Maximum = Value
End Set
End Property
Property [Step]() As Integer
Get
Return ProgressBar1.Step
EndGet
Set(ByVal Value As Integer)
ProgressBar1.Step = Value
End Set
End Property
Public Sub PerformStep()
ProgressBar1.PerformStep()
UpdateLabel()
End Sub
PrivateSub UpdateLabel()
Dim myString As String = ((ProgressBar1.Value * 100) \ ProgressBar1.Maximum).ToString()
myString &= "% Done"
Dim canvas As Graphics = Me.ProgressBar1.CreateGraphics
canvas.DrawString(myString, New Font("Verdana", 8, FontStyle.Regular), New SolidBrush(Color.Red), 90, 4)
canvas.Dispose()
End Sub
to test the control just add the new control inside new windows project and add timer control. timer control code: Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Status.PerformStep() If Status.Maximum = Status.Value Then Timer1.Enabled = False EndSub If you want to reset the timer just join next code to the button or something (i will use a button for the purpose) Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer1.Enabled = False Status.Value = 0 Status.Maximum = 20 Status.Step = 1 Timer1.Enabled = True End Sub HTH Regards P.S. do not hesitate to ask for a demo project if you cannot realize it from the code above ![]() |
|
||||
|
I need a demo how to manage that new control and how to put it into a new project. By the way: why DOES the "transparent"-Backcolor NOT work with the Label and the ProgressBar (as I stated here: http://www.vbdotnetforums.com/showpo...31&postcount=4)
Brainbug |
|
||||
|
Is it possible to get self-made controls in the toolbox, to pick and drapg&drop them to a form, when needed? How did you get your UserControl in there?
Brainbug |
|
||||
|
Quote:
HTH Regards
|
|
||||
|
I'm using .net 2006 and there it says "choose items" and then you have to browse for the dll; now I managed it to use your control. Thank you very much for your support.
Brainbug |
|
||||
|
Quote:
.. suppose typo but, anyway you are wellcome for help ..anytime, if i am able to be of help ... Regards
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|