views:

62

answers:

2

I have a windows form containing a webbrowser that navigates to a site which sends data back in the form of a table. I would like to transfer the data on that table to a application that runs some calculations on the data and then reports whether the calculations were successful or not. If the calculations were sucessful the webbrowser should request more data and repeat the process. If not the code should stop.

The code shown below allows works correctly the first time data is imported to the table. However, when the InvokeMethod is called the data in the table is not refreshed (code not shown indicates that the data in the table is the same). Is there a solution?

   private void cmdRun_Click(object sender, EventArgs e)
    {
            //set reference to button go get a new game
        WebBrowser WB = webBrowser1;
        HtmlElementCollection SudokuTable; HtmlDocument Doc;
        //set reference to the button to refresh the table
        HtmlElement goButton = this.webBrowser1.Document.All["VeryHardLevelStr"];

    RunAgain:
        Doc = WB.Document;     //get a new copy of the info

        //Get the second form, tranfer the data and process it
        Form FormSolver = GetSolverForm();                  //set reference to form
            //set reference to datagrid to transfer data to
        DataGridView dGV1 = GetDGVQ1(FormSolver);  
            //set reference to button that starts processing the data
        Button StartButton = GetNamedButton(FormSolver, "cmdStart");  
            //set reference to checkbox to determine if the processing was ok
        CheckBox CheckBxOK = GetNamedCheckBox(FormSolver, "ckSolutionOK");
            //set a reference to the table with the values
        SudokuTable = Doc.GetElementsByTagName("TABLE");  
            //transfer the values to a table on another form
        TransferDataToSolvingForm(SudokuTable, dGV1);   
            //start code on second form to process the data
        StartButton.PerformClick();  

            //if a solution has been found close the form and request more data 
  //if not solution found let code stop
        if (CheckBxOK.Checked)          
        {
            //user wants to close other form if successful uf CloseOnSuccess is true
            Boolean CloseOnSuccess = this.ckCloseSolverOnSuccess.Checked;   
            if (CloseOnSuccess)
            {
                FormSolver.Close();             //since a solution was arrived at close the form
                goButton.InvokeMember("click"); //Click the key on web browser to request more data

                while (WB.IsBusy == true)               //wait till it has retreived the data
                {
                    System.Threading.Thread.Sleep(50);
                }
            }

            goto RunAgain;                  //go back a reanalyze the new data
        }
    }
A: 

If I understand you correctly, you show the table data in the browser, and this is not being updated after the first time it is loaded. If this is the case, make sure WebBrowser.AllowNavigation is set to true:

Gets or sets a value indicating whether the control can navigate to another page after its initial page has been loaded.

Philip Wallace
Thanks, but that isn't the issue as the AllowNaviation property is set to true.
Bill Corry
A: 

I'm seeing the same behavior.

mdp