I have the following funtion in my ComboBoxControl class, and it only returns to me the control of the comboBox.
The foreach works fine but my problem is how to return the ComboBox, becuse if the ComboBox doesn´t exists I need to return NULL or something else.
How can I return the ComboBox in this function?
public ComboBox getComboBoxControl(string ComboBoxName)
{
ComboBox _bx;
foreach (Control frmControl in frm.Controls)
{
if (frmControl is ComboBox)
{
if (frmControl.Name == ComboBoxName)
{
_bx = (ComboBox)frmControl;
break;
}
}
}
if (_bx /* Something like is Set ?? */ )
{
return _bx;
}
else
{
return null;
}
}