Pass a combobox selected value between window forms

Posted on 2009-04-24
Last Modified: 2013-11-26
I'm trying pass the value of a combo box between two window forms.  I've had a read up on this but I've just ended up very confused!!!

can you please help me with a very simple straight forward method to dothis??

Question by:leap29
    LVL 53

    Expert Comment

    There are so many methods (How many? I don't know) to pass data between forms in Windows application. In this article, let me take four important (easiest) ways of accomplishing this:

    1. Using constructor
    2. Using objects
    3. Using properties
    4. Using delegates

    More info:
    LVL 53

    Expert Comment

    LVL 3

    Accepted Solution

    In form with combo box - create static property which will return selected value.
    In any other form you can use this static property...
        public partial class Form_Withcombo : Form
            private static object selectedValue = string.Empty;
            public static object SelectedValue
                get { return selectedValue; }
            public Form_Withcombo()
                this.comboBox1.SelectedValueChanged += new System.EventHandler(this.comboBox1_SelectedValueChanged);
            private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
                selectedValue = comboBox1.SelectedValue;
        public class Form2 : Form 
            public void F()
                // here you can user Form_WithCombo.SelectedValue

    Open in new window


    Author Closing Comment



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Hire Top Freelancers to Complete C# Projects

    Source the talented Expert Exchange community
    for top quality work on your C# projects.

    Hire the best. Collaborate easily. Get quality work.

    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now