CurrencyManager Question

CurrencyManager Question

Post by Gary Pari » Wed, 30 Mar 2005 05:07:05


I have two books that I purchased, "ADO.NET Step-By-Step" and "Visual Basic
.NET Black Book".

I am reading about data-binding in Windows forms and there is a paragraph
about the CurrencyManager Object which states:

"The CurrencyManager object is fundamental to the Windows Forms
data-binding architecture. Through its properties, methods, and events, the
CurrencyManager object manages the link between a data source and the
controls that display data from the source."

All is good in .NET land so far.

But in the Visual Basic .NET book, it talks about Simple and Complex
data-binding, gives examples, but nothing is said about the CurrencyManager.

Can anyone shed some light on why the CurrencyManager is needed? Why isn't
the binding of the controls enough? Yes, the ADO.NET describes the commands
but no other explanation is given.

Thanks for any input.

Gary
 
 
 

CurrencyManager Question

Post by Cor Ligthe » Wed, 30 Mar 2005 18:37:10

Gary,

There is in US a chat about ADONET, one of the writters of the Microsoft
ADONET books is there almost forever. (David Sceppa).

See for that the message from Jason Cooke which is posted about 4 hours
after yours,

Cor

 
 
 

CurrencyManager Question

Post by Cor Ligthe » Wed, 30 Mar 2005 18:39:25

Gary,

As a more direct answer of your question.

The currencymanager shows you the current position in the control binded to
the datasource.

Therefore when you bind the same datasource to a combobox and a listbox and
you change the current in the combobox, you will see that change in the
listbox as well.

I hope this gives an idea.

Cor
 
 
 

CurrencyManager Question

Post by hartley_aa » Sun, 28 May 2006 01:31:07

Hi,

CurrencyManger has a method called AddNew which well create a new
record in the data that it is bound to (ie a new datarow in a table).
The new record has null values for all of its elements. What I would
like to have is the ability to add a new record using the current
values of the TextBox fields that have been bound to the datasource.

I have tried various solutions to have the code edit the record using
the current values after it has been created, but the null values cause
a 'System.Data.NoNullAllowedException' error. Here is one attempt:

objCurrencyManager.AddNew()
objCurrencyManager.EndCurrentEdit()

Any ideas?

Thanks,
Aaron
 
 
 

CurrencyManager Question

Post by Cor Ligthe » Sun, 28 May 2006 02:51:16

Hartley,

Seems difficult to me, because when you use whatever AddNew method than
there will be a new row created. The CurrencyManager AddNew set direct the
pointer to this new added row and therefore your textbox is nothing at that
moment.

In my opinion is what you try to do not in the line of binded bounds or in
other words.
It does me reminds on that Jewish Witz (joke), that I have more times writen
in this newsgroup.


Cor

< XXXX@XXXXX.COM > schreef in bericht
 
 
 

CurrencyManager Question

Post by hartley_aa » Sun, 28 May 2006 03:59:56

Cor,


The null row is the heavy stone!

In the past I always have coded everything directly against the
datatables. This works great except that I end up with a lot of code
which creates more maintenance overhead. I wanted to try binding and
see if it would be an improvement.

The example in my VS book has the code insert the row into the database
and then reload the datatable from the database. This skirts around
the issue entirely. While this method keeps the datatable very
current, it also has higher network and processing overhead. Some
situations may call for this while others may call for something more
detached and efficient.

Is the AddNew method totally worthless?

Aaron
 
 
 

CurrencyManager Question

Post by Cor Ligthe » Sun, 28 May 2006 15:48:11

I don't think it is worthless, only you have to use an add button first
before you start entering. That is just two times expirience and it is done.

The update button does than everything as well for other updates, but than
complete for all changed rows.

Just my thought,

Cor

< XXXX@XXXXX.COM > schreef in bericht
 
 
 

CurrencyManager Question

Post by Aaro » Wed, 31 May 2006 23:51:03

Cor,

Do you have any example code that you would be willing to share?

Aaron
 
 
 

CurrencyManager Question

Post by Cor Ligthe » Thu, 01 Jun 2006 02:35:04

Aaron,

You mean something as this?

http://www.yqcomputer.com/

Cor

"Aaron" < XXXX@XXXXX.COM > schreef in bericht