marin
13 years agoFrequent Contributor
How to select a dynamically created button in Windows form
Hello all,
in my .NET Win Forms application, there is a scenario where a dynamic number of buttons will be created on a form.
I need to perform a click on a certain button.
Have tried the following (see attached screenshot for name mapping):
but this wouldn't work...
What would be the correct approach?
Many thanks for any hints...
in my .NET Win Forms application, there is a scenario where a dynamic number of buttons will be created on a form.
I need to perform a click on a certain button.
Have tried the following (see attached screenshot for name mapping):
//attempt to access the record with index 5 and to click the button contained there:
var record = Aliases.TestApp.frmMain.MdiClient.frmOverview.pnlContainer.pnl.WinFormsObject("Record")[5];
var button = record.WinFormsObject("btn")[0];
button.Click();
but this wouldn't work...
What would be the correct approach?
Many thanks for any hints...