By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,215 Members | 1,920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,215 IT Pros & Developers. It's quick & easy.

currency manager

P: n/a
Hi,
i have a class "MyClass" with a public property of datatable type. I also
have a form with a public property of type "MyClass". The form has a
datagrid which binds to MyClass.Table datatable. While navigating through
the datagrid rows i can see the current position of MyClass.Table object
through the currency manager (ctype(bindingcontext(Myclass.Table),
currencymanager).position). How can i see the current position from within
MyClass object?

Public Class MyClass

Public Sub New
Mybase.New
Table = Get a Table from SQL DB
End Sub

Private _table as datatable

Public Property Table() as Datatable
Get
Return _Table
End Get
Set (ByVal Value as Datatable)
_table = value
End Set
End Property

End Class

Within a form class ......

Private _sclass as MyClass

Public Property sclass() as MyClass
Get
Return _sclass
End Get
Set (ByVal Value as MyClass)
_sclass = value
End Set
End Property

Me.DataGrid.Datasource = sclass.Table

Thanks,

Theodore
Jan 26 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi,

You would have to pass a reference to the currency manager to
the class.
Ken
---------------
"Theodore" <t@t.com> wrote in message
news:O4*************@TK2MSFTNGP12.phx.gbl...
Hi,
i have a class "MyClass" with a public property of datatable type. I also
have a form with a public property of type "MyClass". The form has a
datagrid which binds to MyClass.Table datatable. While navigating through
the datagrid rows i can see the current position of MyClass.Table object
through the currency manager (ctype(bindingcontext(Myclass.Table),
currencymanager).position). How can i see the current position from within
MyClass object?

Public Class MyClass

Public Sub New
Mybase.New
Table = Get a Table from SQL DB
End Sub

Private _table as datatable

Public Property Table() as Datatable
Get
Return _Table
End Get
Set (ByVal Value as Datatable)
_table = value
End Set
End Property

End Class

Within a form class ......

Private _sclass as MyClass

Public Property sclass() as MyClass
Get
Return _sclass
End Get
Set (ByVal Value as MyClass)
_sclass = value
End Set
End Property

Me.DataGrid.Datasource = sclass.Table

Thanks,

Theodore

Jan 27 '06 #2

P: n/a
Theodore,

You make me curious. your myclass is a bad replica from the dataset class.

Why are you doing that?

Cor
Jan 27 '06 #3

P: n/a
Hi Ken,
that is what i am doing now, but why isn't it possible to get the currency
manager from within the original class where the datatable is defined?
I am trying to understand how the whole thing works but i don't get a clear
picture. The binding context class seems to work only for controls. I can
define a new bindingcontext object in my class and derive the
currencymanager from the Table object. This will give me a currency manager
that is not affected by any action that happens on the Table object from
within a different class. I want MyClass to be the datasource for other
classes that bind to the Table object simultaneously. What ever action takes
place against the MyClass.Table object in any of these classes should
project its results to all other classes too.

For example if you have two datagrids on a form and one datatable as the
datasource, the changes in any of these datagrids will show in the other one
too. What if you have these datagrids on separate forms and the datatable on
a third class? How would you make this work?

Thanks,
Theodore
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi,

You would have to pass a reference to the currency manager to
the class.
Ken
---------------
"Theodore" <t@t.com> wrote in message
news:O4*************@TK2MSFTNGP12.phx.gbl...
Hi,
i have a class "MyClass" with a public property of datatable type. I also
have a form with a public property of type "MyClass". The form has a
datagrid which binds to MyClass.Table datatable. While navigating through
the datagrid rows i can see the current position of MyClass.Table object
through the currency manager (ctype(bindingcontext(Myclass.Table),
currencymanager).position). How can i see the current position from
within MyClass object?

Public Class MyClass

Public Sub New
Mybase.New
Table = Get a Table from SQL DB
End Sub

Private _table as datatable

Public Property Table() as Datatable
Get
Return _Table
End Get
Set (ByVal Value as Datatable)
_table = value
End Set
End Property

End Class

Within a form class ......

Private _sclass as MyClass

Public Property sclass() as MyClass
Get
Return _sclass
End Get
Set (ByVal Value as MyClass)
_sclass = value
End Set
End Property

Me.DataGrid.Datasource = sclass.Table

Thanks,

Theodore


Jan 27 '06 #4

P: n/a
Hi Cor,
i had to simplify things in my explenation to focus on my problem. MyClass
is not just holding a datatable but does a lot more things. I am not trying
to replicate dataset at all. I just want to keep the data presentation in a
seperate object and that's why MyClass is not a window form class but just
another custom class that inherits from another custom class and implements
some custom interfaces. But all this stuff has nothing to do with my problem
and that's why i didn't mentioned them before.

In fact the form that contains the datagrid is also an object of MyClass and
so is another form that has various controls bound to the table's columns. I
just want to keep all of them syncronized at all times. So how can i have a
common binding for both forms and also be able to access it from within
MyClass???

Thanks,
Theodore

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Theodore,

You make me curious. your myclass is a bad replica from the dataset class.

Why are you doing that?

Cor

Jan 27 '06 #5

P: n/a
Theo,

I don't think that it has much sense. I have the idea that you than the
bindingcontex to a method (function) in your class what is than as much work
as writting that sentence as you now and in my opinion less documentive.

http://msdn.microsoft.com/library/de...ntexttopic.asp

However I never did this, and will not try because it has not much sense for
me.

Maybe can you try it yourself.

Cor
"Theo" <t@t.com> schreef in bericht
news:OA****************@TK2MSFTNGP14.phx.gbl...
Hi Cor,
i had to simplify things in my explenation to focus on my problem. MyClass
is not just holding a datatable but does a lot more things. I am not
trying to replicate dataset at all. I just want to keep the data
presentation in a seperate object and that's why MyClass is not a window
form class but just another custom class that inherits from another custom
class and implements some custom interfaces. But all this stuff has
nothing to do with my problem and that's why i didn't mentioned them
before.

In fact the form that contains the datagrid is also an object of MyClass
and so is another form that has various controls bound to the table's
columns. I just want to keep all of them syncronized at all times. So how
can i have a common binding for both forms and also be able to access it
from within MyClass???

Thanks,
Theodore

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Theodore,

You make me curious. your myclass is a bad replica from the dataset
class.

Why are you doing that?

Cor


Jan 27 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.