473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Databinding checkbox

Hi, I'm working with compact framework on winform and a xml dataset,
the databind on textbox work fine but doen't work on checkbox that is
show the check/uncheck correctly but it doesn't save the value, what
can I do?

My sample source:
eSupCorp.DataBindings.Add("Text",oDataView,"SUPCOR PO"); // TextBox
eTatuaggi.DataBindings.Add"Checked",oDataView,"TAT UAGGI"); // Checkbox

Ho provato a salvare {"False","True"}, {"F","T"} ho provato ad
aggiungere: Format e parse ma niente da fare

private void BoolToStringa(object sender, ConvertEventArgs cevent)
{
if(cevent.DesiredType != typeof(bool)) return;
string sCheck = (string) cevent.Value;
if (sCheck.CompareTo("S") == 0)
cevent.Value = true;
else
cevent.Value = false;
}
private void StringaToBool(object sender, ConvertEventArgs e)
{
if ((e.Value is bool) && (e.DesiredType == typeof( string)))
{
bool isTrue= (bool)e.Value;
if (isTrue)
e.Value= "S";
else
e.Value= "N";
}
}

Binding bCheckBox = new Binding("Checked",oDV,"NomeCampo");
bCheckBox.Format+=new ConvertEventHandler(BoolToStringa);
bCheckBox.Parse+= new ConvertEventHandler(StringaToBool);
((CheckBoxEx)oComp).DataBindings.Add(bCheckBox);
Nov 17 '05 #1
0 5143

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeff | last post by:
I am having a behaviour problem with Databinding on a C# WinForm. I have three textboxes and a Checkbox bound to a dataset. The desired behaviour is when I check/uncheck the checkbox, I want to...
2
by: sdeezdaone | last post by:
I've got two tables that are linked by a field. The first table contains a list of items (like a checklist). The second table contains the corresponding a record for each user and each checklist...
1
by: Baskar RajaSekharan | last post by:
Hi, I have one Doubt in C#. I bound one CheckBox control to the Dataset column. when Leave the Checkbox using the Tab, the Value of the Check box is automaticllay set it to Zer 0r False. ...
4
by: aroth | last post by:
I have a basic form with some dropdownlist controls that I would like to populate with items from a database. I keep getting the error "Cannot implicitly convert type...
2
by: Martin | last post by:
Hi, Please can somebody explain how databinding is done on a checkbox list. I have the follwoing code which I would have thought was enough to databind a checkbox, but apparently not. The...
1
by: Tom | last post by:
Hi there I have a little problem here, wich i think is quite strange... I have a dataset, filled from my SQL database. In it are some boolean fields (or bit as SQL server calls them) Now, on...
6
by: M | last post by:
I binding controls to a dataset at design time. I find the checkboxs will cause the program crash when one of these databinding fields is dbnull. The only way for me is not set databindings for...
1
by: novato | last post by:
Hello, this is my first post, I´m new in C# and i´m developing a capture for a test helth for babies (tamiz), I´m making a capture screen with text box and checkbox. For databinding textbox I don´t...
0
by: novato | last post by:
Hello, this is my first post, I´m new in C# and i´m developing a capture for a test helth for babies (tamiz), I´m making a capture screen with text box and checkbox. For databinding textbox I don´t...
1
by: JeffN825 | last post by:
Hi, I've been struggling with a databinding nuance for a bunch of hours now, so I figured I'd post out for help. I need to databind a control to an object. The control does not have a parent. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.