Control name

  • Thread starter Thread starter robert schild
  • Start date Start date
R

robert schild

How do you identify a control in a control collection in a
VB.NET CF app since there's no NAME property available?
You can't use the following:
Dim CTRL as control
for each ctrl in controls
if ctrl.name = "txtName") then
 
Robert,

You can do this (sorry for the C#):

foreach (Control c in this.Controls)
{
if (c == this.cbCustomer)
{
MessageBox.Show("It's the customer control");
break;
}
}

In other words, instead of comparing with the control's name, just compare
with the control object.

Ginny Caughey
Windows Embedded MVP
 
Istread of <if ctrl.name = "txtName"> you should use <if
ctrl Is txtName>

the "Is" keyword compares if controls are the same.
 
Back
Top