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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:27:58+00:00 2026-05-30T14:27:58+00:00

I have a problem with DataBinding in Winforms, Even though I click Cancel on

  • 0

I have a problem with DataBinding in Winforms, Even though I click “Cancel” on the form, the objecte is updated.

I’ve set the property “DialogResult” of the Ok button to “OK”, of the Cancel button to “Cancel”, also, I’ve set the properties “AccesptButton” and “CancelButton” of the form to bnOk and bnCancel.

Here is my code :

Model :

private string code;
public string Code
{
     get { return code; }
     set { SetPropertyValue<string>("Code", ref code, value); }
}

private string libelle;
public string Libelle
{
     get { return libelle; }
     set { SetPropertyValue<string>("Libelle", ref libelle, value); }
}

UI :

public FamilleTiers CurrentFamilleTiers { get; set; }
private void FamilleTiersForm_Load(object sender, EventArgs e)
{
     txCode.DataBindings.Add("Text", CurrentFamilleTiers, "Code");
     txLibelle.DataBindings.Add("Text", CurrentFamilleTiers, "Libelle");
}

Edit function :

public static void EditFamilleTiers(FamilleTiers selectedFamilleTiers)
{
   using (FamilleTiersForm form = new FamilleTiersForm() { CurrentFamilleTiers =  selectedFamilleTiers, Text = selectedFamilleTiers.Libelle })
   {
         if (form.ShowDialog() == DialogResult.OK)
         {
             form.CurrentFamilleTiers.Save();
         }
   }
}

Thanks for your time

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

    When you click cancel on a form data binding does not revert you need to keep a backup copy of the values and if they change replace the new values with the original values. .Net does not know what your wanting to do.

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

Sidebar

Related Questions

I have some problem on databinding to Image 's Source Property. I have a
I have a problem with System.Window.Form.CheckBox databinding. I have code: checkBox1.DataBindings.Add(Checked, _movementsBindingSource, Moved, true);
I have run into a problem w/ my model for databinding in WPF. I
i have problem with autorotate on iphone i set up in all classes -
I have a databinding problem in WPF. I would like to customise a slider
I have a problem with a databinding in WPF. When I try to use
I am new to vaadin and have a databinding problem. I have posted allready
I have a problem with the databinding in wpf, i want to bind a
I have a problem with a databinding. I have a class with properties to
Problem 1: I have a simple winforms app and I want to DataBind my

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.