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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:07:05+00:00 2026-05-13T11:07:05+00:00

I wonder how to obtain feedback from an event? Situation: Let’s say that a

  • 0

I wonder how to obtain feedback from an event?

Situation:

Let’s say that a object (Slave) can produce events(request changing a property). An other object (Master) subscribes to these events, analyzes the changing property value and accepts, or denies this change. Then the feedback is returned to the Slave, and it change or not its property.

Example:

    public class DateChangingEventArgs : EventArgs {
        public DateTime oldDateTime, newDateTime;
        DateChangingEventArgs(DateTime oldDateTime, 
            DateTime newDateTime) {
            this.oldDateTime = oldDateTime;
            this.newDateTime = newDateTime;
        }
    }

    public class MyDateTextBox : TextBox {
        public event EventHandler<DateChangingEventArgs> DateChanging;
        public DateTime MyDate;
        private DateTime myTempDate;

        protected override void OnKeyDown(KeyEventArgs e) {
            base.OnKeyDown(e);

            if (e.KeyCode == Keys.Enter && 
                DateTime.TryParseExact(this.Text, "dd/mm/yyyy", 
                CultureInfo.InvariantCulture, DateTimeStyles.None, 
                out myTempDate)) {                    
                if (!DateChanging == null)
                    DateChanging(this, 
                        new DateChangingEventArgs(MyDate, myTempDate));

                if (feedbackOK) //  here ????????
                    MyDate = myTempDate;
            }
        }
    }

[EDIT]

With your suggestions some modifications in the code am I sure that Cancel is already updated?

public class DateChangingEventArgs : CancelEventArgs

…

public class MyDateTextBox : TextBox
{
    public event EventHandler<DateChangingEventArgs> DateChanging;
    ...
    protected override void OnKeyDown(KeyEventArgs e) {
        if (...)
        {          
            DateChangingEventArgs myRequest;
            if (!DateChanging == null) {
                myRequest = new DateChangingEventArgs(MyDate, myTempDate);
                DateChanging(this,  myRequest);
            }

            // Sure that this value is already updated ??
            if (!myRequest.Cancel) 
                MyDate = myTempDate;
        }
    }
}
  • 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-13T11:07:05+00:00Added an answer on May 13, 2026 at 11:07 am

    You declare your own class and pass an instance of it instead of “EventArgs.Empty”.

    The event hander changes properties on the event object (providing feedback).

    You then check the event args object and check the feedback provided.

    Any questions?

    e.g.

    class FeedbackEventArgs: EventArgs
    {
       public bool IsOk {get; set;}
    }
    ...
    FeedbackEventArgs feedback = new FeedbackEventArgs();
    feedback.IsOK = false;
    if (!DateChanging == null) 
        DateChanging(this, feedback); 
    if (feedback.IsOK) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder about that can I write native SQL to add or delete operations
I wonder if these 2 methods getFromLocation and getFromLocationName obtain information from Google Maps
Wonder if anyone can help. I have a c# web application that uses the
wonder whether someone can help me with the following one... I have a struct
Is it possible to obtain ServletContext from MyPortlet extends MVCPortlet in Liferay? I know
As I know the information about geographic location that a browser has, is from
In Python, you can assign an arbitrary attribute from outside the defining class :
I wonder if anyone can help me or point me in the right direction.
Hi I wonder if someone can help me, I've been banging my head against
Wonder if anyone can help me, the map displays fine but the marker does.

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.