|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
currency manageri 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 Hi,
You would have to pass a reference to the currency manager to the class. Ken --------------- Show quoteHide quote "Theodore" <t@t.com> wrote in message news:O4q5ItqIGHA.740@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 > 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 Show quoteHide quote "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message news:%23dbLl7uIGHA.528@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:O4q5ItqIGHA.740@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 >> > > Theodore,
You make me curious. your myclass is a bad replica from the dataset class. Why are you doing that? Cor 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 Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:%23ES1u7wIGHA.3700@TK2MSFTNGP15.phx.gbl... > Theodore, > > You make me curious. your myclass is a bad replica from the dataset class. > > Why are you doing that? > > Cor > 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/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclassbindingcontexttopic.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 Show quoteHide quote "Theo" <t@t.com> schreef in bericht news:OAy%23rvyIGHA.2900@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]" <notmyfirstn***@planet.nl> wrote in message > news:%23ES1u7wIGHA.3700@TK2MSFTNGP15.phx.gbl... >> Theodore, >> >> You make me curious. your myclass is a bad replica from the dataset >> class. >> >> Why are you doing that? >> >> Cor >> > > |
|||||||||||||||||||||||