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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:32:59+00:00 2026-05-20T14:32:59+00:00

I had implemented a wpf combobox into a winform and now have to somehow

  • 0

I had implemented a wpf combobox into a winform and now have to somehow make it call a function or an event in my winform when the box is changed, as well as be able to change the value from the winform.

main:

namespace main
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            ElementHost elhost = new ElementHost();
            elhost.Size = new Size(174, 24);
            elhost.Location = new Point(93,60);
            MyWPFControl wpfctl = new MyWPFControl();
            elhost.Child = wpfctl;
            this.Controls.Add(elhost);
            elhost.BringToFront();
        }


        public void status_change(int val)
        {
            MessageBox.Show("Box value has changed to:" + Convert.ToString(val)   );
        }

and wpf:

namespace main
{
    /// <summary>
    /// Interaction logic for MyWPFControl.xaml
    /// </summary>
    public partial class MyWPFControl : UserControl
    {
        public MyWPFControl()
        {
            InitializeComponent();

        }


        private void statComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            main.status_change(statComboBox.SelectedIndex);
            /// says:
            /// Error   1   The type or namespace name 'status_change' does not exist in the namespace 'main' (are you missing an assembly reference?)  C:\Users\Robert\documents\visual studio 2010\Projects\XMPP\main\wpf_combo_status.xaml.cs    31  18  main

        }


    }
    }

any idea what I might be doing wrong? Thanks!

  • 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-20T14:32:59+00:00Added an answer on May 20, 2026 at 2:32 pm

    Expose an event in MyWPFControl like:

    public SelectionChangedEventArgs:EventArgs
    {
        public int SelectedIndex {get; private set;}
        public SelectionChangedEventArgs (int selIdx)
        {
            this.SelectedIndex = selIdx;
        }
    }
    
    public partial class MyWPFControl : UserControl
    {
        public event EventHandler<SelectionChangedEventArgs> SelectionChanged;
    
        public MyWPFControl()
        {
            InitializeComponent();
        }
    
        private void statComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            OnSelectionChanged(statComboBox.SelectedIndex);
        }
    
        private void OnSelectionChanged(int selIdx)
        {
            if (SelectionChange != null)
                SelectionChanged(this, new SelectionChangedEventArgs(selIdx));
        }
    }
    

    Then subscribe it in your form, like:

    public Form1()
    {
        InitializeComponent();
    
        ElementHost elhost = new ElementHost();
        elhost.Size = new Size(174, 24);
        elhost.Location = new Point(93,60);
        MyWPFControl wpfctl = new MyWPFControl();
        elhost.Child = wpfctl;
        this.Controls.Add(elhost);
        elhost.BringToFront();
    
        wpfctl.SelectionChanged += myWPFControls_SelectionChanged;
    }
    
    private void myWPFControls_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        status_change(e.SelectedIndex);
    }
    

    P.S.:

    I can’t test it, so there could be some errors, but just to give you the idea… 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF form with a combobox and a textbox (both are databound
I was looking at how some site implemented rounded corners, and the CSS had
I'm new to WPF but I need to implement following functionality: I have a
I lately had the problem of creating add and edit dialogs for my wpf
I have a member in the WPF code behind that is disposable (meaning it
I was reading an article in which the author had implemented an Entity class
I was wondering if anyone had ever implemented multiple Django webservers pointing to a
I have a form which fills some objects of a Collection. I had the
If you had to implement a network broadcast, would you use UDP broadcast or
Me and my friend had a little debate. I had to implement a browser

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.