How do I fire an event in VB.NET code? -


i have form has start button (to allow users run processes on , on if wish), , want send btnstart.click event when form loads, processes start automatically.

i have following function btnstart.click event, how tell visual basic 'pretend has clicked button , fire event'?

i've tried going simple, works. however, visual studio gives me warning variable 'sender' used before has been assigned value, i'm guessing not way it:

dim sender object btnstart_click(sender, new eventargs()) 

i have tried using raiseevent btnstart.click, gives following error:

'btnstart' not event of 'myproject.myformclass

code

imports system.componentmodel  partial public class frmprogress      private bw backgroundworker = new backgroundworker      public sub new()          initializecomponent()          ' set backgroundworker         bw.workerreportsprogress = true         bw.workersupportscancellation = true         addhandler bw.dowork, addressof bw_dowork         addhandler bw.progresschanged, addressof bw_progresschanged         addhandler bw.runworkercompleted, addressof bw_runworkercompleted          ' fire 'btnstart.click' event when form loads         dim sender object         btnstart_click(sender, new eventargs())      end sub      private sub btnstart_click(sender object, e eventargs) handles btnstart.click          if not bw.isbusy = true              ' enable 'more >>' button on form, there details users view             me.btnmore.enabled = true              ' update form control settings correctly formatted when processing starts             set_form_on_start()              bw.runworkerasync()          end if      end sub      ' other functions exist here  end class 

you should send button sender event handler:

btnstart_click(btnstart, new eventargs()) 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -