[Windows Forms] How to synchronize two controls.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ernestasju
    New Member
    • Sep 2009
    • 11

    [Windows Forms] How to synchronize two controls.

    I have two WebBrowser controls. Their all properties are equal at the start.
    The question is how to make second web browser do what the first one does.
    For example when I type text in to search box, text would be typed in both controls.
  • ThatThatGuy
    Recognized Expert Contributor
    • Jul 2009
    • 453

    #2
    Broswer controls dont come with address bars or something like that they just come with the browser pane....

    so you will have to put two textboxes and on text changed event of one text box fill the second address bar(textbox) of the browser....

    Comment

    • smithse
      New Member
      • Jan 2010
      • 3

      #3
      hi,

      I'd probably do what thatthatguy suggested in the post above.
      If your two controls are on separate forms, I'd create a method on each form that accepts a parameter (the web address), and pass that parameter from the event of either your textbox textchanged event, or keypress, or whatever method you're doing to get the address from the textbox to the browser.

      The browser control comes with limited events that are raised, so it all depends on when you want theses "changes", or your "sync" event to occurs.

      Comment

      • ernestasju
        New Member
        • Sep 2009
        • 11

        #4
        Facts:
        1) Two different controls are in the different containers;
        2) Both controls are of WebBrowser type and named w1 and w2;
        3) Both have same start page: google.com;
        4) Then I type text in one search textbox in w1,
        same text is being typed into other search textbox in w2. (and vice versa)
        5) When I have typed "microsoft" and pressed Search button in w1,
        w2 should show search results for "microsoft" too;
        6) When I refresh the w1, w2 refreshes too.
        -------------------------------------------------------------------------------------------------------------------
        This is the synchronization which I want to implement.
        Just dont know how...

        Comment

        • ThatThatGuy
          Recognized Expert Contributor
          • Jul 2009
          • 453

          #5
          on text changed event of one textox1 update the text of textbox2 with textbox 1

          on click event of button1 call button2....

          private void button1_Click(o bject sender,MouseEve ntArgs e)
          {
          //do some button1 action and then programmaticall y invoke the button2
          button2.Perform Click();
          }

          Comment

          Working...