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 5848667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:53:29+00:00 2026-05-22T12:53:29+00:00

I want to fill a combobox on Form1 , when the OK button on

  • 0

I want to fill a combobox on Form1 , when the OK button on Form2 is clicked.

First, the Load Form2 button on Form1 is clicked to display Form2.
Then, Form2 appears, and if OK(Button on Form2) is pressed then the Form1 ComboBox must be filled with values from a SQL SERVER database table.

public partial class FORM1 : Form
{
     public void LoadValue()
        {
            string query = "SELECT FullName FROM Studs ";

            SqlCommand cmd = new SqlCommand(query, FORM1conn);

                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    FORM1COMBOBOX.Items.Add(reader.GetString(0));
                }
        }
}

public partial class FORM2 : Form
{
        private void FORM2_OK_Button_Click(object sender, EventArgs e)
        {
               //HERE I WANT TO CALL THE  LOADVALUE() METHOD OF FORM1  ????????
         }
}

enter image description here

EDIT:
In form2.cs :

public partial class FORM2 : Form
{

    public  FORM2(SqlConnection connfromFORM3)
    {
        Form2Conn = connfromFORM3;
        InitializeComponent();
    }

    private Form1 form1;
    public SELECTGROUPHEADDIALOG(FORM1 form1) : this()
    {
        this.form1 = form1;
    }

        private void FORM2_OK_Button_Click(object sender, EventArgs e)
        {
               //HERE I WANT TO CALL THE  LOADVALUE() METHOD OF FORM1  ????????
         }
}
  • 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-05-22T12:53:30+00:00Added an answer on May 22, 2026 at 12:53 pm

    Updated

    You can try passing Form1 instance in the constructor of Form2

    Example:

     public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2(this);
            form2.Show();
        }
    
        internal void TestMethod()
        {
            throw new NotImplementedException();
        }
    }
    
    public partial class Form2 : Form
    {
        private Form1 form1;
    
        public Form2()
        {
            InitializeComponent();
        }
    
        public Form2(Form1 form1)
            : this()
        {
            // TODO: Complete member initialization
            this.form1 = form1;
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            form1.TestMethod();
        }
    }
    

    Updated

    try this:

    public  FORM2(SqlConnection connfromFORM3, FORM1 form1)
    {
        this.form1 = form1;
        Form2Conn = connfromFORM3;
        InitializeComponent();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using JSON for first time... and want to fill my datagrid with
Using VS2005 with C# I want to fill the combobox by using the table
i want to fill a combobox with data from the database when the page
Using VB.Net I want to fill a combobox with table values by using 3
I want to fill items in a combobox, each of them has different behaviour.
I want to fill an array in javascript that takes all the values out
I want to fill a ListView without an array of all the same things.
I want to fill jqGrid from a stored procedure, there was 1 good example
I want to fill all cells with the same control. What I have now
I simply want to fill-up cells in my spreadsheet from a VBA function. By

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.