progress bar - C# progressbar drawstring on form load -


is there way write default text on progressbar in c# ?

this isn't working in form_load, works fine on button click...

using (graphics gr = progressbar1.creategraphics()) {     stringformat sf = new stringformat(stringformatflags.nowrap);     sf.alignment = stringalignment.center;     gr.drawstring("hello world",                    new font("arial", 10.0f, fontstyle.regular),                   new solidbrush(color.black),                    progressbar1.clientrectangle,                    sf);                 } 

thanks in advance

you can set 1 time timer event on 1 option.

timer t = new timer();  form_load() {     t.interval = 1000;     t.start(); }  static void t_elapsed(object sender, elapsedeventargs e) {     //one time event     t.stop();     using (graphics gr = progressbar1.creategraphics())     {         stringformat sf = new stringformat(stringformatflags.nowrap);         sf.alignment = stringalignment.center;         gr.drawstring("hello world",              new font("arial", 10.0f, fontstyle.regular),             new solidbrush(color.black),              progressbar1.clientrectangle,              sf);                     } } 

one note on this:

as progressbar.value changed; progressbar graphics change , overwrite text have drawn. comment nolonar overlay progressbar label , set in front of progressbar may be more needs.

otherwise, you'd have handle redrawing of progressbar graphics change.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -