PC Review


Reply
Thread Tools Rate Thread

Databinding w/Update

 
 
=?Utf-8?B?SGFycnkgUmlkZGxl?=
Guest
Posts: n/a
 
      18th Apr 2005
Hi All,

I am under the impression that databinding allows a control to be updated
automatically by the interface when the underlying value changes. However,
many of my controls will not update after the initial display. If I have a
boolean property and I bind it to a checkbox's checked property, I should be
able to change the boolean from true to false and observe the checkbox go
from checked to unchecked. Is there something else I should be doing or am I
totally off-base?
--
Thanks,
Harry
 
Reply With Quote
 
 
 
 
Norman Yuan
Guest
Posts: n/a
 
      18th Apr 2005
Are you talking about Win Form App? If yes, showing some code may help to
see what happens.

"Harry Riddle" <(E-Mail Removed)> wrote in message
news:5880E953-7BC5-4AF6-A54B-(E-Mail Removed)...
> Hi All,
>
> I am under the impression that databinding allows a control to be updated
> automatically by the interface when the underlying value changes.

However,
> many of my controls will not update after the initial display. If I have

a
> boolean property and I bind it to a checkbox's checked property, I should

be
> able to change the boolean from true to false and observe the checkbox go
> from checked to unchecked. Is there something else I should be doing or

am I
> totally off-base?
> --
> Thanks,
> Harry



 
Reply With Quote
 
Peter Huang [MSFT]
Guest
Posts: n/a
 
      19th Apr 2005
Hi Harry,

Here is some code for your reference.
private bool bChecked;
public bool MyChecked
{
set{bChecked = value;}
get{return bChecked;}
}
private void Form1_Load(object sender, System.EventArgs e)
{
this.DataBindings.Add("MyChecked",this.checkBox1,"Checked");
this.checkBox1.CheckedChanged+=new
EventHandler(checkBox1_CheckedChanged);
}

private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
this.Text = MyChecked.ToString();
}

Also here is a link you may take a look.
http://groups.google.co.jp/groups?hl...3.0404210520.2
5a73e87%40posting.google.com&rnum=5&prev=/groups%3Fhl%3Dzh-CN%26lr%3D%26q%3D
%2522checkBox1.DataBindings.Add%2522


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Dmytro Lapshyn [MVP]
Guest
Posts: n/a
 
      19th Apr 2005
Hi Harry,

For the databinding to work properly, each bindable property on a class or
on a component must be complemented with an event of type EventHandler. This
event must be named <Property>Changed, where <Property> is the name of your
property. E.g. if your property is named IsAvailable, the event must be
named IsAvailableChanged.

This applies if your properties are real properties and not 'virtual' ones
exposed through ICustomTypeDescriptor.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


"Harry Riddle" <(E-Mail Removed)> wrote in message
news:5880E953-7BC5-4AF6-A54B-(E-Mail Removed)...
> Hi All,
>
> I am under the impression that databinding allows a control to be updated
> automatically by the interface when the underlying value changes.
> However,
> many of my controls will not update after the initial display. If I have
> a
> boolean property and I bind it to a checkbox's checked property, I should
> be
> able to change the boolean from true to false and observe the checkbox go
> from checked to unchecked. Is there something else I should be doing or
> am I
> totally off-base?
> --
> Thanks,
> Harry


 
Reply With Quote
 
=?Utf-8?B?ZGNo?=
Guest
Posts: n/a
 
      25th May 2005
I have the same problem and can't figure out what to do.
I have a window application with a textbox(VS2003). I set the databinding
property, text, of the textbox to one of the column of the dataset.
I assume when I change the textbox value, it will update the column of the
table automatically. When it does not update the table, I added code in the
textchange method of the textbox to do an update, such as:
oleDBDataAdapter1.Update(dataSet1);
and it still does not update the table.
Does anyone have any clue how to make this work?

"Dmytro Lapshyn [MVP]" wrote:

> Hi Harry,
>
> For the databinding to work properly, each bindable property on a class or
> on a component must be complemented with an event of type EventHandler. This
> event must be named <Property>Changed, where <Property> is the name of your
> property. E.g. if your property is named IsAvailable, the event must be
> named IsAvailableChanged.
>
> This applies if your properties are real properties and not 'virtual' ones
> exposed through ICustomTypeDescriptor.
>
> --
> Sincerely,
> Dmytro Lapshyn [Visual Developer - Visual C# MVP]
>
>
> "Harry Riddle" <(E-Mail Removed)> wrote in message
> news:5880E953-7BC5-4AF6-A54B-(E-Mail Removed)...
> > Hi All,
> >
> > I am under the impression that databinding allows a control to be updated
> > automatically by the interface when the underlying value changes.
> > However,
> > many of my controls will not update after the initial display. If I have
> > a
> > boolean property and I bind it to a checkbox's checked property, I should
> > be
> > able to change the boolean from true to false and observe the checkbox go
> > from checked to unchecked. Is there something else I should be doing or
> > am I
> > totally off-base?
> > --
> > Thanks,
> > Harry

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databinding & Update in Webform virlinz Microsoft VB .NET 1 16th Sep 2005 04:28 AM
When does DataBinding update? How to force an update? Patrick B Microsoft C# .NET 0 24th Feb 2005 11:30 PM
Update or Databinding? =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?= Microsoft ASP .NET 2 23rd Nov 2004 09:31 PM
Databinding a webform for update Arne Microsoft ASP .NET 0 15th Aug 2003 05:22 PM
Forcing a Databinding to update Darran Shelton Microsoft C# .NET 0 23rd Jul 2003 12:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:08 PM.