We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

binding checkbox to non-boolean database fields

Thread ID:





2589 Feb 2,2003 11:23 PM UTC Feb 13,2003 12:44 AM UTC WinForms 1
Tags: FAQ
Asked On February 2, 2003 11:23 PM UTC

I'm stuck dealing with a database that uses Char-1 fields for flags. Literally 'Y' or 'N'. What's the best approach to binding a checkbox to such a feild? Of course I need to be able to show the value, as well as change it. I guess I'll have to make a custom control, subclassing the checkbox. However, I dont' know what events to try to tap into. Is there some kind of event for "reading binding value" that I can override and give it "Y" when the box is checked? Also an event for "Setting binding value" that I can override and check when I see a 'Y' Any help greatly appreciated.

Replied On February 13, 2003 12:44 AM UTC

CheckBox myCk = new CheckBox(); DataBinding db = new Binding( "Checked", myDataSet, "tablename.fieldname" ); myCk.DataBindings.Add( db); // inject delegates that translate bet. field and checkbox db.Format += new ConvertEventHandler( fromDbToControl ); db.Parse += new ConvertEventHandler( fromControlToDb );


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon