-
Apr 19th, 2022, 01:55 PM
#1
Thread Starter
Hyperactive Member
putting text to progressbar
how to put text to progressbar (not value,im making progress button i need to put string)
-
Apr 19th, 2022, 04:39 PM
#2
Re: putting text to progressbar
create a user control with a progress bar and a label...
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
-
Apr 20th, 2022, 10:23 AM
#3
Thread Starter
Hyperactive Member
Re: putting text to progressbar
man theres no transparent on .net labels,i can do it in only com based vb6
-
Apr 20th, 2022, 11:27 AM
#4
Re: putting text to progressbar
Originally Posted by gaouser
man theres no transparent on .net labels,i can do it in only com based vb6
A label has a transparent background on .Net, I am really not understanding your problem here.
-
Apr 20th, 2022, 02:42 PM
#5
Thread Starter
Hyperactive Member
Re: putting text to progressbar
PlausiblyDamp i use 2010 ( most compatible vb with win7)(i use win7 and im sending message on it)
-
Apr 20th, 2022, 03:44 PM
#6
Re: putting text to progressbar
Then I have great news for you! I consulted the documentation and the Label class exposes the BackColor property as early as .NET 1.1 and the Color struct also exposes Color.Transparent property as early as .NET 1.1.
So Delaney's original advice is perfectly applicable:
Originally Posted by Delaney
create a user control with a progress bar and a label...
-
Apr 20th, 2022, 06:43 PM
#7
Re: putting text to progressbar
Personally I would have (or at least tried to) create a new class, inherit the progress bar, add a new property to hold the text, and then draw the text onto the progbar ...
-tg
-
Apr 21st, 2022, 05:40 AM
#8
Re: putting text to progressbar
Gaouser, I'm guessing you want to display the percentage of progress over a progress bar. The only way to do this is to create your own custom progress bar.
Add a class to your project and name it "CustomProgressBar", and place this code inside it:
Code:
Inherits ProgressBar
Public Sub New()
Me.SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint, True)
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim rect As Rectangle = Me.ClientRectangle
Dim g As Graphics = e.Graphics
ProgressBarRenderer.DrawHorizontalBar(g, rect)
If Me.Value > 0 Then
Dim rect2 As Rectangle = New Rectangle(rect.X, rect.Y, CInt(Math.Round((CSng(Me.Value) / Me.Maximum) * rect.Width)), rect.Height)
ProgressBarRenderer.DrawHorizontalChunks(g, rect2)
End If
Using f As Font = New Font(FontFamily.GenericMonospace, 10)
Dim size As SizeF = g.MeasureString(String.Format("{0} %", Me.Value), f)
Dim location As Point = New Point(CInt(((rect.Width / 2) - (size.Width / 2))), CInt(((rect.Height / 2) - (size.Height / 2) + 2)))
g.DrawString(String.Format("{0} %", Me.Value), f, Brushes.Black, location)
End Using
End Sub
Now build or rebuild your project, and CustomProgressBar will show in your toolbox for use like the regular progress bar, except it will display the percentage of progress.
So you know it works:
Last edited by Peter Porter; Apr 22nd, 2022 at 08:38 AM.
-
Apr 21st, 2022, 05:55 AM
#9
Re: putting text to progressbar
If you don't mind adding a C# class project to your Visual Studio solution, check out the following C# class project. Once added to your solution, reference the project in your project, add the progress bar to your form.
Sample VB usage
Code:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextProgressBar1.Value = 100 Then
TextProgressBar1.ProgressColor = Color.LightGreen
TextProgressBar1.Value = 0
End If
TextProgressBar1.Value = TextProgressBar1.Value + 10
If TextProgressBar1.Value < 20 Then
TextProgressBar1.CustomText = "Stage 1"
ElseIf TextProgressBar1.Value > 30 AndAlso TextProgressBar1.Value < 50 Then
TextProgressBar1.CustomText = "Stage 2"
ElseIf TextProgressBar1.Value > 99 Then
TextProgressBar1.CustomText = "Done"
TextProgressBar1.ProgressColor = Color.Yellow
End If
End Sub
End Class
Then of course, why can't this be in VB.NET? Well convert using a C# to VB.NET converter but the progressbar works just fine as is or another member here may do the conversion. One of the great things about .NET is languages, C# and VB.NET work well together.
-
Apr 21st, 2022, 07:18 AM
#10
Re: putting text to progressbar
Originally Posted by kareninstructor
If you don't mind adding a C# class project to your Visual Studio solution, check out the following C# class project. Once added to your solution, reference the project in your project, add the progress bar to your form.
Sample VB usage
Code:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextProgressBar1.Value = 100 Then
TextProgressBar1.ProgressColor = Color.LightGreen
TextProgressBar1.Value = 0
End If
TextProgressBar1.Value = TextProgressBar1.Value + 10
If TextProgressBar1.Value < 20 Then
TextProgressBar1.CustomText = "Stage 1"
ElseIf TextProgressBar1.Value > 30 AndAlso TextProgressBar1.Value < 50 Then
TextProgressBar1.CustomText = "Stage 2"
ElseIf TextProgressBar1.Value > 99 Then
TextProgressBar1.CustomText = "Done"
TextProgressBar1.ProgressColor = Color.Yellow
End If
End Sub
End Class
Then of course, why can't this be in VB.NET? Well convert using a C# to VB.NET converter but the progressbar works just fine as is or another member here may do the conversion. One of the great things about .NET is languages, C# and VB.NET work well together.
I found what I posted from a YouTube video, but it was in C#. Just had to make a minor tweak to it while converting to VB, removing InitializeComponent() to get it to work.
Love your progress bar!
Last edited by Peter Porter; Apr 22nd, 2022 at 05:06 AM.
-
Apr 21st, 2022, 11:49 AM
#11
Thread Starter
Hyperactive Member
Re: putting text to progressbar
@Peter Porter im having a problem on chunks
-
Apr 21st, 2022, 12:57 PM
#12
Re: putting text to progressbar
Originally Posted by gaouser
@Peter Porter im having a problem on chunks
Bidet or toilet paper?
-
Apr 22nd, 2022, 12:53 AM
#13
Re: putting text to progressbar
Originally Posted by gaouser
@Peter Porter im having a problem on chunks
Your fault if you're all backed-up!
You should've ate healthy!
Last edited by Peter Porter; Apr 22nd, 2022 at 01:28 AM.
-
Apr 22nd, 2022, 05:18 AM
#14
Re: putting text to progressbar
Originally Posted by gaouser
@Peter Porter im having a problem on chunks
Gaouser, what are you writing about? I'm not psychic!
Chunks doesn't tell me anything! Why do you believe that it's enough?
How is this related the progress bar problem?
Did me and Karen solve the problem that this thread is about?
Last edited by Peter Porter; Apr 22nd, 2022 at 06:21 AM.
-
Apr 22nd, 2022, 01:51 PM
#15
Re: putting text to progressbar
he cannot answer to you he has been banned
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
-
Apr 22nd, 2022, 03:04 PM
#16
Re: putting text to progressbar
Woah.. .what happened? Wha'd I miss?
-tg
-
Apr 22nd, 2022, 03:55 PM
#17
Re: putting text to progressbar
Originally Posted by techgnome
Woah.. .what happened? Wha'd I miss?
-tg
I don't think it was a single thing that happened, I would imagine it was the totality of nonsense they were posting that made it abundantly clear that they would never be more than a significant annoyance on this site.
-
Apr 23rd, 2022, 02:21 PM
#18
Lively Member
Re: putting text to progressbar
Originally Posted by techgnome
Personally I would have (or at least tried to) create a new class, inherit the progress bar, add a new property to hold the text, and then draw the text onto the progbar ...
-tg
Good practice I believe this is protected programming you are indicating.
-
Apr 23rd, 2022, 02:23 PM
#19
Lively Member
Re: putting text to progressbar
Originally Posted by mmx88_ValidUser
Good practice I believe this is protected programming you are indicating.
And proper rendering you want speed you ll learn some protected techniques with the controls.
-
Apr 23rd, 2022, 04:33 PM
#20
Re: putting text to progressbar
Originally Posted by mmx88_ValidUser
Originally Posted by techgnome
Personally I would have (or at least tried to) create a new class, inherit the progress bar, add a new property to hold the text, and then draw the text onto the progbar ...
-tg
Good practice I believe this is protected programming you are indicating.
ValidUser, use Google Translate to translate comments. Techgnome's comment doesn't indicate anything towards protected programming, so your reply to him doesn't make sense.
Last edited by Peter Porter; Apr 23rd, 2022 at 04:43 PM.
-
Apr 23rd, 2022, 04:34 PM
#21
Re: putting text to progressbar
Originally Posted by mmx88_ValidUser
Originally Posted by mmx88_ValidUser
Good practice I believe this is protected programming you are indicating.
And proper rendering you want speed you ll learn some protected techniques with the controls.
Do you also talk to yourself at home? I hope not!
-
Apr 23rd, 2022, 04:36 PM
#22
Re: putting text to progressbar
D'oh! This comment was a copy of the previous before. Not sure how that happened.
Last edited by Peter Porter; Apr 23rd, 2022 at 04:42 PM.
-
Apr 23rd, 2022, 05:10 PM
#23
Lively Member
Re: putting text to progressbar
Originally Posted by Peter Porter
ValidUser, use Google Translate to translate comments. Techgnome's comment doesn't indicate anything towards protected programming, so your reply to him doesn't make sense.
Are you trying to big fish your self into the penalty box mister.
-
Apr 23rd, 2022, 05:22 PM
#24
Re: putting text to progressbar
Originally Posted by mmx88_ValidUser
Are you trying to big fish your self into the penalty box mister.
What does that even mean? If it's a mixed metaphor it's so mixed as to have no meaning at all.
My usual boring signature: Nothing
-
Apr 24th, 2022, 03:34 PM
#25
Thread Starter
Hyperactive Member
Re: putting text to progressbar
hi everyone my ban lifted )) i read all from internet explorer (i didnt login from it) but i only check in 14:00 pm
wow what happened here whatd i miss
Last edited by gaouser; Apr 24th, 2022 at 03:39 PM.
-
Apr 24th, 2022, 03:36 PM
#26
Thread Starter
Hyperactive Member
Re: putting text to progressbar
Originally Posted by Peter Porter
Do you also talk to yourself at home? I hope not!
AHAHAHAHAHAHHAHAHAHAHAHAHAAAAAAHAHAHAHHAHAHAHA i cant stop i laugh for 5 MINUTES
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
|