G
Guest
Hi,
Is there a way to get the control that has the focus on a form?
The following code should at least compile but VS says some path don't have
a return value. Any way to bypass the compiler on this?
But maybe someone has a better way?
Thanks,
Sitar.
===
static public Control GetFocusedControl(Control parent)
{
if (parent.Focused)
{
return parent;
}
else
{
if (parent.Controls.Count>0)
{
foreach (Control c in parent.Controls)
{
return GetFocusedControl(c);
}
}
else
{
return null;
}
}
}
Is there a way to get the control that has the focus on a form?
The following code should at least compile but VS says some path don't have
a return value. Any way to bypass the compiler on this?
But maybe someone has a better way?
Thanks,
Sitar.
===
static public Control GetFocusedControl(Control parent)
{
if (parent.Focused)
{
return parent;
}
else
{
if (parent.Controls.Count>0)
{
foreach (Control c in parent.Controls)
{
return GetFocusedControl(c);
}
}
else
{
return null;
}
}
}