FindControl equivalent?

  • Thread starter Thread starter Wade
  • Start date Start date
W

Wade

ASP.NET has the ability to find a control in the control namespace (part of
System.Web.UI.Control):

Dim myControl1 As Control = FindControl("TextBox2")

Does the .NET compact framework have an equivalent way to get a control? I
know I can loop through the controls in the form, but I don't want to do
that as there could be a lot of controls. Since I know the name of the
control, I'd rather just refer to it directly.

Thanks!

Wade
 
I don't think it does. You should check out the ControlEx in OpenNetCf.
But you could just create a library call:

Control FindControl(Form f, string controlName)
{
foreach(Control c in f.Controls)
{
if(string.Compare(c.Name, controlName, true) ==0)
{
return c;
}
}
}
 
The code for it is on my Blog, so you don't necessarily need the SDF to do
it.

-Chris
 
Back
Top