Groups | Blog | Home
all groups > dotnet windows forms databinding > july 2004 >

dotnet windows forms databinding : Rtf-Binding in a Richtextbox sets HasChanges in the Dataset to True ? even without changes?



Liz Helmecke
7/23/2004 11:46:59 AM
Hello NG,

VS 2003 / VB.NET / SQL-Server-Windows-App:

On a Windows-Form are some Textboxes and Combos and so on, and 2
Richttextboxes.
All these are bound to the Dataset:
Databinding.Add(new Binding("Text", ...)) or, if it is a Richtextbox:
....(new Binding("Rtf", ...)

Now, after the User has edited anything and leaves the Record, I want to ask
him "Do you want to save your changes?"
So, I check if myDataSet.HasChanges.
If it has no Changes, the record can be left immediately. If it has, the "Do
you want to..."-Message is popping up.

If the Richtextboxes-Binding is with the "Text"-Property, everything works
fine.
But if I use the "Rtf"-Property for the Binding, the Dataset tells me
always, HasChanges is True, even if it's not!

Since I need the formatting-possibilities and need to save it in the
database, how could I solve this issue?

Any ideas? I would be glad.
Thank you!
Liz

Andrew Smith (Infragistics)
7/25/2004 11:18:27 AM
That's because there is no RtfChanged event; the only way that the binding
class can know when the property has changed is if it finds an event that
matches the property name plus changed. If it doesn't find one, it will
always assume it to be dirty.

[quoted text, click to view]

Liz Helmecke
7/26/2004 10:16:14 AM
Thank you, Andrew,

for this explanation!
Now I understand WHY it is this way.
Alright, so we have to use the Modified-Property of each control instead,
not the HasChanges-Property of the Dataset.

By the way, nice to get the explanation from an Infragistics-Man!
We are working with infragistics-Controls right now, and are pretty glad
with them most of the time, but often it is hard to understand how they
work.
Does Infragistics have an RTF-Control? We didn't find one.

Is there a Newsgroup like this one to place questions and answers about
Infragistics Controls / Netadvantage Suite?

Thank you
Liz

Andrew Smith (Infragistics)
7/30/2004 11:43:03 AM
Glad I could help explain the problem. No, Infragistics doesn't have an rtf
control.

With regards to infragistics newsgroups, yes, there are several depending
upon which control you are using. There's a list on the website:
http://devcenter.infragistics.com/DevCom/NewsGroups.Aspx

[quoted text, click to view]

Andrew Smith (Infragistics)
7/30/2004 11:46:58 AM
The issue with this is knowing when to invoke the event. You may be able to
get away with deriving from the RichTextBox, adding an RtfChanged event,
then override OnTextChanged method and after/before calling the base
implementation, raise the RtfChanged event. That presupposes that a text
changed event will fire even if the rtf markup is changed (e.g. changing the
selection's font); if it doesn't you may need to override the WndProc (which
will mean this will require unmanaged code rights) and try using the various
richtext specific messages - e.g. EM_SETPARAFORMAT.

[quoted text, click to view]

Gilles E.
7/30/2004 3:05:31 PM
Hello,

Many thanks for this question and this good answer. I was searching for it
since a long time.
Would it be possible to create a class inherited from RichTextBox with a
RtfChanged event ? How would it be ?

Gilles

"Andrew Smith (Infragistics)" <productmanager@infragistics.com> schrieb im
Newsbeitrag news:uEockqlcEHA.2268@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button