Hello
I've had some struggle with different controls and to declare this I've written a small routine inside nunit.
public void WriteParentListOfControl(object control)
{
object c = control;
string str = "";
try {
str = Name(c);
} catch (Exception)
{
str = "#";
}
c = Parent(c);
for (int i = 0; i < 6; i++)
{
try {
str = Name(c) + "." + str;
} catch (Exception)
{
str = "#." + str;
}
c = Parent(c);
}
System.Console.WriteLine(str);
}
This code generates an output of the control names and the names of the control parents in the same way they can adressed inside of the nunit test routines.
For example in normal cases you can adress a button named "btnNew" on the form tFrmGLBatch like ...
btnNew = new ButtonTester("btnNew", tFrmGLBatch);
Because there are more than one buttons you can use a more specific name like
btnNew = new ButtonTester("tpgBatches.btnNew", tFrmGLBatch);
In this case tpgBatches is the name of the parent on first level.
In the very first steps this works well but while my code was increasing, I got some difficult errors. The routine above shows the problem. Let us have a look onto the four hits related to the control name txtLedgerNumber
tableLayoutPanel1.pnlLedgerInfo.tableLayoutPanel2.txtLedgerNumber
pnlContent.pnlInfo.tableLayoutPanel1.txtLedgerNumber
pnlContent.pnlInfo.tableLayoutPanel1.txtLedgerNumber
pnlContent.pnlInfo.tableLayoutPanel1.txtLedgerNumber
That means: The name of three different controls is unique.
Calculated up to the 6th level:
ucoBatches.pnlContent.pnlInfo.tableLayoutPanel1.pnlLedgerInfo.tableLayoutPanel2.txtLedgerNumber
tabGLBatch.tpgJournals.ucoJournals.pnlContent.pnlInfo.tableLayoutPanel1.txtLedgerNumber
tabGLBatch.tpgTransactions.ucoTransactions.pnlContent.pnlInfo.tableLayoutPanel1.txtLedgerNumber
tabGLBatch.tpgAttributes.ucoAttributes.pnlContent.pnlInfo.tableLayoutPanel1.txtLedgerNumber
Here are the diferences ...
For reference and for discussion I'll add the complete list of control names from the GL-Batches module.
Best regards
Wolfgang