Checkbox databind always modifies row

R

Robert Eastham

Hi

I have a form that binds a few textboxes and a checkbox to a view.
It seems that with the checkbox databound the row is always put
into a modified state.

If I do not bind the checkbox all works fine.

Am using CF SP2.

What am I doing something here?

Thanks for any help!!

In the code here I am simply moving to the next row..nothing is changed on
the form

temp = ds.Tables[0].Rows[0].RowState.ToString() ; <-- temp = "Unchanged"
panel1.BindingContext[dv].Position += 1 ;
temp = ds.Tables[0].Rows[0].RowState.ToString() ; <-- temp = "Modified"


The binding statement

chkGrabDaily.DataBindings.Add("Checked", dv, "GrabDailyHistory") ;

The DataView is simply
dv.Table = ds.Tables[0] ;

The dateview field

? dv[0]["GrabDailyHistory"]
{true}
System.ValueType: {System.Boolean}
False: 0
FalseString: "False"
m_value: true
True: 1
TrueString: "True"


The DataSet field
? ds.Tables[0].Columns["GrabDailyHistory"]
{System.Data.DataColumn}
System.ComponentModel.MarshalByValueComponent: {System.Data.DataColumn}
_columnName: "GrabDailyHistory"
_columnPrefix: ""
_columnUri: null
AllowDBNull: false
allowNull: false
autoIncrement: false
AutoIncrement: false
autoIncrementCurrent: 0
AutoIncrementSeed: 0
autoIncrementSeed: 0
autoIncrementStep: 1
AutoIncrementStep: 1
Caption: "GrabDailyHistory"
caption: null
ColumnMapping: Element
columnMapping: Element
ColumnName: "GrabDailyHistory"
Computed: false
DataType: {"System.Boolean"}
dataType: {"System.Boolean"}
defaultValue: {true}
DefaultValue: {true}
description: ""
dttype: ""
encodedColumnName: null
EncodedColumnName: "GrabDailyHistory"
errors: 0
Expression: ""
expression: <undefined value>
extendedProperties: <undefined value>
ExtendedProperties: {System.Data.PropertyCollection}
HasData: true
hashCode: 1624
Item: <cannot view indexed property>
Item: <cannot view indexed property>
MaxLength: -1
maxLength: -1
Namespace: ""
onPropertyChangingDelegate: <undefined value>
Ordinal: 8
ordinal: 8
Prefix: ""
readOnly: false
ReadOnly: false
simpleType: <undefined value>
SimpleType: <undefined value>
sortIndex: <undefined value>
SortIndex: {System.Data.Index}
Storage: {System.Data.Common.BooleanStorage}
storage: {System.Data.Common.BooleanStorage}
table: {System.Data.DataTable}
Table: {System.Data.DataTable}
Unique: false
unique: false
 
I

Ilya Tumanov [MS]

I was not aware of this problem. Which property you're binding to?
You know you can't bind to Checked since CheckedChanged event is missing in
CF?
If you're binding to CheckState with appropriate Parse/Format event
handlers on Binding, please post some code.
One more thing... Is Parse/Format are hooked up before you Binding is added
to a control? If not, that won't work and needs to be changed.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
T

Tim Wilson

You know you can't bind to Checked since CheckedChanged
event is missing in CF?
Really? I've had a boolean column in a DataTable bound to the Checked
property of a CheckBox and it appeared to work properly in both directions.

--
Tim Wilson
..Net Compact Framework MVP

"Ilya Tumanov [MS]" said:
I was not aware of this problem. Which property you're binding to?
You know you can't bind to Checked since CheckedChanged event is missing in
CF?
If you're binding to CheckState with appropriate Parse/Format event
handlers on Binding, please post some code.
One more thing... Is Parse/Format are hooked up before you Binding is added
to a control? If not, that won't work and needs to be changed.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Florian Lutz" <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
Subject: Re: Checkbox databind always modifies row
Date: 27 Dec 2004 04:39:35 -0800
Organization: http://groups.google.com
Lines: 4
Message-ID: <[email protected]>
References: <[email protected]>
NNTP-Posting-Host: 203.217.8.66
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1104151179 10009 127.0.0.1 (27 Dec 2004 12:39:39 GMT)
X-Complaints-To: (e-mail address removed)
NNTP-Posting-Date: Mon, 27 Dec 2004 12:39:39 +0000 (UTC)
In-Reply-To: <[email protected]>
User-Agent: G2/0.2
Complaints-To: (e-mail address removed)
Injection-Info: f14g2000cwb.googlegroups.com; posting-host=203.217.8.66;
posting-account=p47-Lg0AAAAhHq7M5IcRlr6CsUsxa6tD
Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!news.glorb.com!postnews.google.com!f14g2000cwb.go
oglegroups.com!not-for-mail
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.compactframework:67568
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

has anyone found a solution to this problem?

florian
 
I

Ilya Tumanov [MS]

Correction: you CAN bind to it, but data source won't be updated if you
change it as it would on desktop.
Try this demo which binds one check box to another to see the difference.
Click on a button to choose binding property, now try changing first check
box...

Best regards,

Ilya

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace DTCSGUI
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.Button button2;

/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.button2 = new System.Windows.Forms.Button();
//
// button1
//
this.button1.Location = new System.Drawing.Point(24, 192);
this.button1.Size = new System.Drawing.Size(104, 20);
this.button1.Text = "Checked";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// checkBox1
//
this.checkBox1.Location = new System.Drawing.Point(40, 32);
this.checkBox1.Text = "checkBox1";
//
// checkBox2
//
this.checkBox2.Location = new System.Drawing.Point(40, 72);
this.checkBox2.Text = "checkBox2";
//
// button2
//
this.button2.Location = new System.Drawing.Point(24, 216);
this.button2.Size = new System.Drawing.Size(104, 20);
this.button2.Text = "CheckState ";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button2);
this.Controls.Add(this.checkBox2);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.button1);
this.Text = "Form1";

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
// [STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e)
{
this.checkBox2.DataBindings.Clear();
Binding b = new Binding("Checked", this.checkBox1, "Checked");
this.checkBox2.DataBindings.Add(b);
}

private void button2_Click(object sender, System.EventArgs e)
{
this.checkBox2.DataBindings.Clear();
Binding b = new Binding("CheckState", this.checkBox1, "CheckState");
this.checkBox2.DataBindings.Add(b);

}

}
}


This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM>
References: <[email protected]>
Subject: Re: Checkbox databind always modifies row
Date: Mon, 27 Dec 2004 14:32:09 -0500
Lines: 66
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1478
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host:
cpe00045af65bf7-cm014210012048.cpe.net.cable.rogers.com 24.103.185.244
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.compactframework:67599
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
You know you can't bind to Checked since CheckedChanged
event is missing in CF?
Really? I've had a boolean column in a DataTable bound to the Checked
property of a CheckBox and it appeared to work properly in both directions.

--
Tim Wilson
.Net Compact Framework MVP

"Ilya Tumanov [MS]" said:
I was not aware of this problem. Which property you're binding to?
You know you can't bind to Checked since CheckedChanged event is missing in
CF?
If you're binding to CheckState with appropriate Parse/Format event
handlers on Binding, please post some code.
One more thing... Is Parse/Format are hooked up before you Binding is added
to a control? If not, that won't work and needs to be changed.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Florian Lutz" <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
Subject: Re: Checkbox databind always modifies row
Date: 27 Dec 2004 04:39:35 -0800
Organization: http://groups.google.com
Lines: 4
Message-ID: <[email protected]>
References: <[email protected]>
NNTP-Posting-Host: 203.217.8.66
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1104151179 10009 127.0.0.1 (27 Dec 2004 12:39:39 GMT)
X-Complaints-To: (e-mail address removed)
NNTP-Posting-Date: Mon, 27 Dec 2004 12:39:39 +0000 (UTC)
In-Reply-To: <[email protected]>
User-Agent: G2/0.2
Complaints-To: (e-mail address removed)
Injection-Info: f14g2000cwb.googlegroups.com; posting-host=203.217.8.66;
posting-account=p47-Lg0AAAAhHq7M5IcRlr6CsUsxa6tD
Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!news.glorb.com!postnews.google.com!f14g2000cwb.go
 
T

Tim Wilson

Ok, thanks for the clarification.

--
Tim Wilson
..Net Compact Framework MVP

"Ilya Tumanov [MS]" said:
Correction: you CAN bind to it, but data source won't be updated if you
change it as it would on desktop.
Try this demo which binds one check box to another to see the difference.
Click on a button to choose binding property, now try changing first check
box...

Best regards,

Ilya

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace DTCSGUI
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.Button button2;

/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.button2 = new System.Windows.Forms.Button();
//
// button1
//
this.button1.Location = new System.Drawing.Point(24, 192);
this.button1.Size = new System.Drawing.Size(104, 20);
this.button1.Text = "Checked";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// checkBox1
//
this.checkBox1.Location = new System.Drawing.Point(40, 32);
this.checkBox1.Text = "checkBox1";
//
// checkBox2
//
this.checkBox2.Location = new System.Drawing.Point(40, 72);
this.checkBox2.Text = "checkBox2";
//
// button2
//
this.button2.Location = new System.Drawing.Point(24, 216);
this.button2.Size = new System.Drawing.Size(104, 20);
this.button2.Text = "CheckState ";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button2);
this.Controls.Add(this.checkBox2);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.button1);
this.Text = "Form1";

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
// [STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e)
{
this.checkBox2.DataBindings.Clear();
Binding b = new Binding("Checked", this.checkBox1, "Checked");
this.checkBox2.DataBindings.Add(b);
}

private void button2_Click(object sender, System.EventArgs e)
{
this.checkBox2.DataBindings.Clear();
Binding b = new Binding("CheckState", this.checkBox1, "CheckState");
this.checkBox2.DataBindings.Add(b);

}

}
}


This posting is provided "AS IS" with no warranties, and confers no rights.
Subject: Re: Checkbox databind always modifies row
Date: Mon, 27 Dec 2004 14:32:09 -0500
Lines: 66
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1478
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host:
cpe00045af65bf7-cm014210012048.cpe.net.cable.rogers.com 24.103.185.244
cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.compactframework:67599
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
You know you can't bind to Checked since CheckedChanged
event is missing in CF?
Really? I've had a boolean column in a DataTable bound to the Checked
property of a CheckBox and it appeared to work properly in both directions.

--
Tim Wilson
.Net Compact Framework MVP

"Ilya Tumanov [MS]" said:
I was not aware of this problem. Which property you're binding to?
You know you can't bind to Checked since CheckedChanged event is
missing
in
CF?
If you're binding to CheckState with appropriate Parse/Format event
handlers on Binding, please post some code.
One more thing... Is Parse/Format are hooked up before you Binding is added
to a control? If not, that won't work and needs to be changed.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Florian Lutz" <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
Subject: Re: Checkbox databind always modifies row
Date: 27 Dec 2004 04:39:35 -0800
Organization: http://groups.google.com
Lines: 4
Message-ID: <[email protected]>
References: <[email protected]>
NNTP-Posting-Host: 203.217.8.66
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1104151179 10009 127.0.0.1 (27 Dec 2004
12:39:39 GMT)
X-Complaints-To: (e-mail address removed)
NNTP-Posting-Date: Mon, 27 Dec 2004 12:39:39 +0000 (UTC)
In-Reply-To: <[email protected]>
User-Agent: G2/0.2
Complaints-To: (e-mail address removed)
Injection-Info: f14g2000cwb.googlegroups.com; posting-host=203.217.8.66;
posting-account=p47-Lg0AAAAhHq7M5IcRlr6CsUsxa6tD
Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!news.glorb.com!postnews.google.com!f14g2000cwb.go
 
F

Florian Lutz

binding to checkstate works perfectly :)
i didn't realize that a missing checkedchanged event causes the problem
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top