CurrencyManager and Classes

  • 9 years ago

    Hi,

    I have created a class on my own which reads a XML file from C: drive. The class has similar looks as below (not all the code is shown here).

    Public Class ABC

       dim ds as new dataset
       dim dt as new datatable

        public sub new()
        mybase.new()
        GetData()
        end sub

        Private sub GetData
        try
            ds.readxml(application.startuppath & "\filename.xml", xmlreadmode.readschema)
            catch ex as filenotfoundexception
            ...do something
        finally
        dt = ds.tables("xyz")
        end try
         end sub

    end class

    The above is all fine (unless someone can tell me what I am doing wrong from the above). The problem and the question that I have is : How do I add a CurrencyManager for the Datatable mentioned in the code above in code?

    Could someone tell me how to do this?

    Thanks & Best Regards
    TempleGate

  • 9 years ago

    Thanks Atul for replying and trying to assist...but...

    I have already tried what you have said above...maybe...my query was not clear enough.

     See, I am trying to use a currencymanager inside a brand new (self created from blank) class which does not belong to any other class nor is derived from any other class other than the default system "Object" (base) class. Therefore, the second line that you mentioned "myCurrencyManager = CType(me.BindingContext(dt), CurrencyManager) " gives me an error saying "BindingContext" is not declared or something in the same likes.

     Hope I made myself clear.

    Rgds

    TempleGate

  • 9 years ago

    Great help...still...but !!! again

    I think you have created a Form and within that form is where you are trying to create and use the CurrencyManager. Whereas I am trying to create a Class from scratch...ie...I go to New Project and select Class Library as the type of project and start fromt there. I have tried something else and seems to be working...but do not know if it is the correct way forward...do tell me if it is or not if you know.

     See...what I did is as follows :

    public Class ABC : Inherits Systems.windows.forms.control

    ....rest of the code goes in between here

    end class

     With the above Underlined line added to my class...my class inherits all the public properties and methods for the Control Class. But now, my only question is...is this the correct way...will this way of creating my class end me up with some bugs/problems in the future. The reason why I have this doubt is because...if you read the help section for the System.Windows.Forms.Control...it will say that this class is inherited for anything that needs a visual interface...like a button...or any other control that you and me would use on a form.

     Let me know your views.

    Rgds

    TempleGate

  • 9 years ago

    No. You're inheriting a class based on control, and by doing it this way, you will have to build your own currencymager; which is not recommended. If you want to add a currency manager just reference System.Windows.Forms to your app, and if you want to add your own functionality to the CurrencyManager, inherit from System.Windows.Forms.BindingManagerBase; although you're going to have to do a lot of overriding and implementing.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Never trust a programmer in a suit.” - Anonymous