In your
button6_Click()
, you create a new instance of GeckoWebBrowser, but it is a local object. So it's null in SetText1 function.
You should put the declaration of GeckoWebBrowser Browser as a class array of type GeckoWebBrowser:
List<GeckoWebBrowser> BrowserList = new List<GeckoWebBrowser>();
Then each time you create a new tab, create a new browser object, then the tab index will be equivalent to the browser's index in the list:
Skybound.Gecko.GeckoWebBrowser Browser = new Skybound.Gecko.GeckoWebBrowser();
BrowserList.Add(Browser);
In the
SetText1()
function, you should pass the selected tab index
void SetText1(int index, string attribute, string attName, string value)
{
Skybound.Gecko.GeckoElementCollection tagsCollection = BrowserList[index].Document.GetElementsByTagName("input");
...
}
When you call SetText1() function
SetText1(tabControl2.SelectedIndex, "name", "income", "aaa");