Venkatgvi
asked on
C# + is there a single line function which gives the name of a control?
Is there a single line function which gives the name of a control, if it exists in a specific form/handle by passing the control type
private bool IsControlExists(Type type)
{
foreach (Control item in this.Controls)
{
if (item.GetType() == type)
return true;
}
return false;
}
If the control is inside another container (panel, groupbox, etc) then it won't be found...
...you would need a RECURSIVE routine to search the entire Form.
...you would need a RECURSIVE routine to search the entire Form.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
As Idle mind said, i can recursively loop across all the controls to find the statusbar object, but my current requirement is to use a predefined function or an API to solve the issue.
hi,
i dont think that they is any single line api, if in another control just write a function to loop and get the control out using typeof
i dont think that they is any single line api, if in another control just write a function to loop and get the control out using typeof
first the contol is called with the name and if there is you will need to pass the name of the control into the function
think of that