Ok so i believe i understand your question. You were loading some html into your web browser component but the text input was not being populated with HI as you specify in your question.
From what i saw/wrote it is because the document had not finished loading by the time it was trying to populate the textbox with HI. So by using the DocumentCompleted Event Handler that will cause the web browser to wait till the document has loaded properly and then run your code to populate the textbox.
I use google as the example.
public Form1()
{
InitializeComponent();
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
private void AddText_Click(object sender, EventArgs e)
{
webBrowser1.Url = new Uri(@"http://google.com");
}
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
foreach (HtmlElement he in webBrowser1.Document.All.GetElementsByName("q"))
{
he.SetAttribute("value", "HI");
}
}
Is this what you were looking for? The way i understand it i believe so.