Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9003393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:42:23+00:00 2026-06-16T00:42:23+00:00

i have added a usercontrol dynamically to a panel of winform i have added

  • 0

i have added a usercontrol dynamically to a panel of winform
i have added the control dynamically so i want to validate the control in the winform so i have used this method

   private bool mobilemanu()
    {
        return panel1.Controls.OfType<UserControl1>().Select(uc => uc.comboBox1).Any(cb => cb.Text == String.Empty);
    }

and in the button click event i used

       private void button2_Click(object sender, EventArgs e)
    {
        bool mobil = mobilemanu();

        if (!mobil)
{
    //do this
}
    else
{
    //do that
}
}

also along with such i used this code for showing which control is not filled properly
but it is only showing first control as errored
i am a newbie to programming so i am little bit confused here

         private void mobilemanuval()
    {
        bool val = mobilemanu();
        if (val == true)
        {
            foreach (Control ctrl in panel1.Controls)
            {
                if (ctrl is UserControl1)
                {
                    UserControl1 myCrl = ctrl as UserControl1;

                    {
                        if (myCrl.comboBox2.Text == string.Empty)
                        {
                            errorProvider1.SetError(myCrl.comboBox1, "entersomething");
                        }
                        if (myCrl.comboBox2.Text == string.Empty)
                        {
                            errorProvider1.SetError(myCrl.comboBox2, "entersomething");
                        }

                    }

                }
            }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:42:24+00:00Added an answer on June 16, 2026 at 12:42 am

    Maybe you just mixed up controls because their names only differ in last letter of the name (digit)? Does this work:

                        if (myCrl.comboBox1.Text == string.Empty)
                        {
                            errorProvider1.SetError(myCrl.comboBox1, "entersomething");
                        }
                        if (myCrl.comboBox2.Text == string.Empty)
                        {
                            errorProvider1.SetError(myCrl.comboBox2, "entersomething");
                        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a usercontrol used in a masterpage. I have added a page with
I have a dynamically created button that is being added to an update panel
I have created user control container (panel actually) which dynamically adding and removing user
I have a page that has 3 used controls that are dynamically added to
I have added a usercontrol to my project like this: Public Sub clickAutoDrillLeft(ByVal sender
I have a UserControl. Within this control I wish to draw ellipses. The problem
Basically, I have a drop down list and a dynamically added user control. The
I have a UserControl which I have added to my web.config <add tagPrefix=BCF src=~/controls/MyMessageBox.ascx
WPF controls have certain properties (UserControl.Resources, UserControl.CommandBindings) that can have items added to them
I have created a wpf application into which I have added a user control

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.