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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:55:16+00:00 2026-05-10T20:55:16+00:00

I have written a control in C# that derives from System.Windows.Forms.Control. I have added

  • 0

I have written a control in C# that derives from System.Windows.Forms.Control. I have added a property Selected to which I want to databind to a business entity using a BindingSource.

I’ve implemented the PropertyNameChanged pattern by adding a SelectedChanged event that I fire when the Selected property is changed.

This is my code:

public partial class RateControl : Control {     [Category('Property Changed')]     public event EventHandler SelectedChanged;      public int Selected     {       get       { return m_selected; }       set       {         if (m_selected != value)         {           m_selected = value;           OnSelectedChanged();           Invalidate();         }       }     }      protected virtual void OnSelectedChanged()     {       if (this.SelectedChanged != null)         this.SelectedChanged(this, new EventArgs());     } } 

When I bind to the Selected property, I see the event being subscibed to. The event is also fired when the property changes.

However the business entity is not updated. I don’t even see the getter of the Selected property being accessed.

What am I missing?

  • 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. 2026-05-10T20:55:17+00:00Added an answer on May 10, 2026 at 8:55 pm

    Have you got the binding’s update mode set to DataSourceUpdateMode.OnPropertyChanged? Either via binding.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;, or using one of the DataBindings.Add(...) overloads.

    The following works for me to push values to the business object…

    using System; using System.Diagnostics; using System.Windows.Forms;  class MyForm : Form {     public MyForm()     {         MyBusinessObject obj = new MyBusinessObject();         Button btn = new Button();         btn.Click += delegate { Foo++; };         DataBindings.Add('Foo', obj, 'Bar', false, DataSourceUpdateMode.OnPropertyChanged);         DataBindings.Add('Text', obj, 'Bar');         Controls.Add(btn);     }      private int foo;     public event EventHandler FooChanged;     public int Foo     {         get { return foo; }         set         {             if (foo != value)             {                 foo = value;                 Debug.WriteLine('Foo changed to ' + foo);                 if (FooChanged != null) FooChanged(this, EventArgs.Empty);             }         }     } }  class MyBusinessObject {     private int bar;     public event EventHandler BarChanged;     public int Bar     {         get { return bar; }         set         {             if (bar != value)             {                 bar = value;                 Debug.WriteLine('Bar changed to ' + bar);                 if (BarChanged != null) BarChanged(this, EventArgs.Empty);             }         }     } }  static class Program {     [STAThread]     static void Main()     {         Application.Run(new MyForm());     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer The best answer I can come up with is to… May 11, 2026 at 11:07 am
  • added an answer One difference I see in reviewing the two is that… May 11, 2026 at 11:06 am
  • added an answer Five states isn't too complex for a state machine, but… May 11, 2026 at 11:06 am

Related Questions

I have written a control in C# that derives from System.Windows.Forms.Control. I have added
I have written a site in Prototype but want to switch to jQuery. Any
I have written a ruby script which opens up dlink admin page in firefox
I have written a DLL that uses MS Word to spell check the content
I have written a watir script that downloads files. One of the files it
I have written a Windows service that allows me to remotely run and stop
I have written a web app in PHP which makes use of Ajax requests
I have written a CSS sprite auto-generator which takes selected images out of the
I have written a windows service using the Apache.NMS and Apcahe.NMS.ActiveMQ (version 1.0) libraries.
I have written a program in C to parse large XML files and then

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.