I have two forms. When a button is clicked in one of them, I want to open the other one and fill a textbox in it. I tried with the code below but it gives an error that says "Unsupported Pattern".
Here is my code:
private void button1_Click(object sender, EventArgs e)
{
string automationId = "Form1";
string newTextBoxValue = "user1";
var condition = new PropertyCondition(AutomationElement.AutomationIdProperty, automationId);
var textBox = AutomationElement.RootElement.FindFirst(TreeScope.Subtree, condition);
ValuePattern vPattern = (ValuePattern)textBox.GetCurrentPattern(ValuePattern.Pattern);
vPattern.SetValue(newTextBoxValue);
}