0

How to foreach loop controls for guna or bunifu framework ? I want to check if a TextBox is null or not.

private void btn_save_Click(object sender, EventArgs e)
{
            foreach (Control obj in Panel.Controls)
            {
                //if using normal TextBox it work..
                if (obj is Guna2TextBox)
                {
                    if (obj.Text == "")
                    {
                        MessageBox.Show("Action connot be perform. All fields are required to be fill up.");
                        return;
                    }
                }
            }
}

1 Answers1

0

Use a Guna Panel instead of a normal Panel then it should work (tried with latest Guna Version)

I used that Code for testing:

foreach (Control obj in guna2Panel1.Controls)
{
    //if using normal TextBox it work..
    if (obj is Guna2TextBox)
    {
        if (obj.Text == "")
        {
            MessageBox.Show("Action connot be perform. All fields are required to be fill up.");
            return;
        }
    }
}

You can also use obj.Text == string.Empty instead of obj.Text == ""