one form triggering a event in another form

How do I get one form event to trigger a event in a differant form

I want get the check_changed event to do a event in differant form , from the form which the checkbox is placed any ideas !!!!



Answer this question

one form triggering a event in another form

  • magicalclick

    Total newbie to vb.net, But good at pulling things apart to find how they work.
    Thank god for google !!!

    any chance of a quick code example

    I want to build a command_line string from check boxes
    eg
    public Sub update_status <=== in form 1

    if form2s-checkbox1 checked then command_line +="First box "
    if form2s-checkbox2 checked then command_line +="Second box"
    form1s status_label.text = command_line

    end sub

    it works but I want changing the checkboxes to update the status label.

    I tried to directly change the status_label from from2 check_change evernt and call the update_status sub routine.
    I`ve found that changing a labels.text from a differant form won`t change the text in the label, which I know must be a problem which scope.


  • Shahzad.K.Y

    Create a delegate in the form that has the checkbox. Then attach it to an instance in the other form. When the check box is checked, fire the event, it will call the function in the other form.



  • Husnu Kaplan

    Hi,

    A simple workaround of this is making the event public in scope. So that you can access the event outside of your form and directly execute it. But be sure that you only have one instance of your form, because if you have multiple instance, then calling the event from a single instance won\t fire the event on the other instances...


    cheers,

    Paul June A. Domag


  • MrTovson

    I`ve tried calling a common event , but it just reset what ever I change at the end of the sub routine.

    I think I`ve over complexed it have a startup module a main form plus 2 set up forms.
    It`s time for a rebuilt and cut it down to a main form which resizes to make a setup form.

    I`ve tried making a simple version to test to see if I can change a lable in a differant form and I can it that ...

    Thats what you get for digging your self in a hole.

  • MarshallR

    Making events public is a terrible idea, IMO. That is what delegates are for. It is a quick solution, but it's a hack.

    http://www.google.com.au/search hl=en&q=vb.net+delegate+example&meta=

    All the articles from that search look like good ones, to get an idea how to use delegates.



  • one form triggering a event in another form