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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:58:14+00:00 2026-05-22T01:58:14+00:00

Is it possible to do this? I need to use: this.ControlName.DataBindings.Add (…) so I

  • 0

Is it possible to do this? I need to use:

this.ControlName.DataBindings.Add (...)

so I can’t define logic other than bind my enum value to a bool.

For example:

(DataClass) Data.Type (enum)

EDIT:

I need to bind Data.Type which is an enum to a checkbox’s Checked property. So if the Data.Type is Secure, I want the SecureCheckbox to be checked, through data binding.

  • 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-22T01:58:15+00:00Added an answer on May 22, 2026 at 1:58 am

    Winforms binding generates two important and useful events: Format and Parse.

    The format event fires when pulling data from a source into a control and the Parse event fires when pulling data from a control back into the data source.

    If you handle these events you can alter/retype the values going back and forth during binding.

    For example here are a couple of example handlers for these events:

     public static void StringValuetoEnum<T>(object sender, ConvertEventArgs cevent)
     {
          T type = default(T);
          if (cevent.DesiredType != type.GetType()) return;
          cevent.Value = Enum.Parse(type.GetType(), cevent.Value.ToString());
     }
    
     public static void EnumToStringValue<T>(object sender, ConvertEventArgs cevent)
     {
          //if (cevent.DesiredType != typeof(string)) return;
          cevent.Value = ((int)cevent.Value).ToString();
     }
    

    And here is some code attaching these event handlers:

     List<NameValuePair> bts = EnumHelper.EnumToNameValuePairList<LegalEntityType>(true, null);
     this.cboIncType.DataSource = bts;                
     this.cboIncType.DisplayMember = "Name";
     this.cboIncType.ValueMember = "Value";
    
     Binding a = new Binding("SelectedValue", this.ActiveCustomer.Classification.BusinessType, "LegalEntityType");
     a.Format += new ConvertEventHandler(ControlValueFormatter.EnumToStringValue<LegalEntityType>);
     a.Parse += new ConvertEventHandler(ControlValueFormatter.StringValuetoEnum<LegalEntityType>);
     this.cboIncType.DataBindings.Add(a);
    

    So in your case you can just create a SecEnum to Bool handler for the format event and within that do something like:

     SecEnum se = Enum.Parse(typeof(SecEnum), cevent.Value.ToString());
     cevent.Value = (bool)(se== SecEnum.Secure);
    

    and then reverse that during parse.

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

Sidebar

Related Questions

Is something like this possible with synchronized , or do I need to use
I need to generate Entities/Object from selected tables - not all. Is this possible
Is this a possible function? I need to check if a variable is existent
Is this combination possible at all? If yes, will I still need to buy
I don't think this is possible, but if is then I need it :)
I need a quick yes/no answer on this... Is it possible to get a
I need something like this http://jonraasch.com/blog/a-simple-jquery-slideshow but w/o the absolute positioning. Is it possible?
First of all I'm not sure this is even possible, however I need to
I Need This Output.. 1 3 5 2 4 6 I Want to use
Is this possible at all and how? Update: I need this because I create

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.