Evening, I have the following code, in a static class which helps my userInterface partial class. Whenever i get to the the section which checks if either the combobox/textbox is visible:
if (cb.Visible == true)
&
if (tb.Visible == true)
its always false even if the controls are visible on the form.
Any ideas?
Thanks
public static bool VerifyTableLayoutControlsContainData(TableLayoutPanel tlp)
{
foreach (Control input in tlp.Controls)
{
ComboBox cb = input as ComboBox;
if(cb != null)
{
if (cb.Visible == true)
{
if (string.IsNullOrEmpty(cb.SelectedItem.ToString()))
{
return false;
}
}
}
TextBox tb = input as TextBox;
if (tb != null)
{
if (tb.Visible == true)
{
if (string.IsNullOrEmpty(tb.Text))
{
return false;
}
}
}
}
return true;
}

Edit1:
UserInterface code
private void uiBtnDataVerification_Click(object sender, EventArgs e)
{
if (VerifyingData != true)
{
AllInputsContainDataCsvFileVerificationStage = true;
//Check all inputs have something in them
InputsContainDataCsvFileVerificationStage();
if (AllInputsContainDataCsvFileVerificationStage == false)
{
UiHelper.UpdateLog("One or more inputs has not been specified.", uiTxtOperationLog);
return;
}
...
}
else
{
//Cancel permanent cancellation token.
}
}
public void InputsContainDataCsvFileVerificationStage()
{
....
if (UiHelper.VerifyTableLayoutControlsContainData(uiTableLayoutPanelColumnDataTypes)) { }
else
{
AllInputsContainDataCsvFileVerificationStage = false;
}
....
}
Original code is in the UiHelper class
Edit2: As per Toms suggestion i have made the following changes
public userInterface()
{
InitializeComponent();
uiTableLayoutPanelColumnDataTypes.VisibleChanged += new EventHandler(notifyMe);
uiCBColumn1DataType.VisibleChanged += new EventHandler(notifyMe1);
SortedColumnNames = new List<TextBox>();
SortedDataTypes = new List<ComboBox>();
AllInputsContainDataCsvFileVerificationStage = true;
}
public void notifyMe1(object sender, EventArgs e)
{
bool temp = uiCBColumn1DataType.Visible;
MessageBox.Show("its been changed");
}
public void notifyMe(object sender, EventArgs e)
{
bool temp = uiTableLayoutPanelColumnDataTypes.Visible;
MessageBox.Show("its been changed");
}
before clicking the button, i checed what cb1 visibility property was set to and it was True. I still get false when i try to check via the original method.
im stumped!!
Edit3:
It seems that when i click on the second tab, the comboBox’s visible property = false.
Does anyone know why this might be??
From my comment: