How to draw graphics onto a control
Post your C# code snippets in here.
4 posts
Page 1 of 1
Lets say for instance you have a webbrowser and you want the webbrowser url in the progressbar without using labels this is how you do it
Add a progressbar first of course
and then add a timer enable it and have it have an interval of 1
then double click it and put
Add a progressbar first of course
and then add a timer enable it and have it have an interval of 1
then double click it and put
Code: Select all
{
Font SFont = new Font("Courier New", 8);
SolidBrush SBrush = new SolidBrush(Color.Black);
Graphics g = progressBar1.CreateGraphics();
StringFormat SFormat = new StringFormat();
g.DrawString(Webbrowser1.url, SFont, SBrush, 5, 5, SFormat);
SFont.Dispose();
SBrush.Dispose();
g.Dispose();
}
Last edited by Bogoh67 on Sun Oct 16, 2011 8:20 am, edited 1 time in total.
A progressbar has a paint event so you can just put the code into the paint.
By the way, if you create Graphics g over and over again it will cause a memory leak. You should dispose it or create it once outside the timer
By the way, if you create Graphics g over and over again it will cause a memory leak. You should dispose it or create it once outside the timer
yea i knew i was forgetting something
SFont.dispose();
SBrush.dispose();
Right?
SFont.dispose();
SBrush.dispose();
Right?
Bogoh67 wrote:yea i knew i was forgetting somethingalso g.Dispose();
SFont.dispose();
SBrush.dispose();
Right?
and maybe stringformat too but idk
4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023