|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Currency Managercould be challenging. Is there any sample or article, which describes, how to synchronize two dataviews bound to the same data table? This is the scenario: dvDataView1 is bound to Dataset.DataTable. dvDataView2 is bound to DataSet.DataTable. Both dataview 1 & 2 are bound ot the same datatable in the same dataset. But both of these have their own currency manager (am I right here?) What I need is, even after filtering & sorting on dvDataView2, when a record is selected, the currencymanager 's position on dvDataView1 should be updated. How can I do this?......... I've searched a lot online, can't seem to find an answer. Thanks Isn't this just a reposting of the problem you're already discussing?
Robin S. ---------------------- Show quoteHide quote "Hemang Shah" <hem***@hemang.net> wrote in message news:%23OLMd6feHHA.4604@TK2MSFTNGP06.phx.gbl... > Currencymanger is a boon, but making it work in out of the box situation > could be challenging. > > Is there any sample or article, which describes, how to synchronize two > dataviews bound to the same data table? > > This is the scenario: > > dvDataView1 is bound to Dataset.DataTable. > dvDataView2 is bound to DataSet.DataTable. > > Both dataview 1 & 2 are bound ot the same datatable in the same dataset. > > But both of these have their own currency manager (am I right here?) > > What I need is, even after filtering & sorting on dvDataView2, when a > record is selected, the currencymanager 's position on dvDataView1 should > be updated. > > How can I do this?......... I've searched a lot online, can't seem to > find an answer. > > Thanks > > Hemang,
> Only if you create "new" dataviews. Otherwise they point to everything the > But both of these have their own currency manager (am I right here?) > No. same. In fact it are the defaultviews of the tables. In other words, all your controls binded to the same dataview or reference to that will have the same row as the currentrow This kind of things is easy to try by the way. Cor Robin, Yes its the same issue, I posted it under a more meaningful heading,
Thanks Cor, Maybe I was not clear in what I said. There are "two" different dataviews (not just one referencing the other) The reason I need two different dataview is because, all the controls on the form are bound to the first dataview. I want to display a datagrid which the user can filter by some criteria, If I use the same dataview for this then the records on the main form are filtered too. I dont want that. I want only the datagrid to be filtered. So I created another dataview, which works fine, because now the filtering of this second dataview does not affect the main form as its bound to the first dataview. Where I'm stuck is that, once the user selects a record in the datagrid which is bound to the second dataview, I want that particular record to be displayed in the main form which is bound to the first dataview. and Cor, I did try this on the form, if I bound both the form & datagrid to the same dataview (or a reference to it), you are right, the currencymanager.position is in sync. and selecting one record, selects the same in the other. But filtering one also filters the other, which I don't want and so I tried with a second dataview, which can be filtered independantly but now is not in sync. The only way its not in sync is because it would have its own currencymanager isn't it? Thanks Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:us85kbjeHHA.4556@TK2MSFTNGP04.phx.gbl... > Hemang, >> >> But both of these have their own currency manager (am I right here?) >> > No. > > Only if you create "new" dataviews. Otherwise they point to everything the > same. In fact it are the defaultviews of the tables. > > In other words, all your controls binded to the same dataview or reference > to that will have the same row as the currentrow > > This kind of things is easy to try by the way. > > Cor > Hemang,
I don't see the "New" keyword in your messages. dv as dataview = myoldDataview this is just a reference dvnieuw as New dataview(MyTable) this is a new dataview with its own currencymanager. Cor Show quoteHide quote "Hemang Shah" <hem***@hemang.net> schreef in bericht news:%23Wg%23nojeHHA.1388@TK2MSFTNGP05.phx.gbl... > Robin, Yes its the same issue, I posted it under a more meaningful > heading, Thanks > > Cor, > > Maybe I was not clear in what I said. > > There are "two" different dataviews (not just one referencing the other) > > The reason I need two different dataview is because, all the controls on > the form are bound to the first dataview. > > I want to display a datagrid which the user can filter by some criteria, > If I use the same dataview for this then the records on the main form are > filtered too. I dont want that. I want only the datagrid to be filtered. > So I created another dataview, which works fine, because now the filtering > of this second dataview does not affect the main form as its bound to the > first dataview. > > Where I'm stuck is that, once the user selects a record in the datagrid > which is bound to the second dataview, I want that particular record to be > displayed in the main form which is bound to the first dataview. > > and Cor, I did try this on the form, if I bound both the form & datagrid > to the same dataview (or a reference to it), you are right, the > currencymanager.position is in sync. and selecting one record, selects > the same in the other. But filtering one also filters the other, which I > don't want and so I tried with a second dataview, which can be filtered > independantly but now is not in sync. The only way its not in sync is > because it would have its own currencymanager isn't it? > > Thanks > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:us85kbjeHHA.4556@TK2MSFTNGP04.phx.gbl... >> Hemang, >>> >>> But both of these have their own currency manager (am I right here?) >>> >> No. >> >> Only if you create "new" dataviews. Otherwise they point to everything >> the same. In fact it are the defaultviews of the tables. >> >> In other words, all your controls binded to the same dataview or >> reference to that will have the same row as the currentrow >> >> This kind of things is easy to try by the way. >> >> Cor >> > > Answer in C#
Dataview dv = new DataView(TheTable); Cor Show quoteHide quote "Hemang Shah" <hem***@hemang.net> schreef in bericht news:%23Wg%23nojeHHA.1388@TK2MSFTNGP05.phx.gbl... > Robin, Yes its the same issue, I posted it under a more meaningful > heading, Thanks > > Cor, > > Maybe I was not clear in what I said. > > There are "two" different dataviews (not just one referencing the other) > > The reason I need two different dataview is because, all the controls on > the form are bound to the first dataview. > > I want to display a datagrid which the user can filter by some criteria, > If I use the same dataview for this then the records on the main form are > filtered too. I dont want that. I want only the datagrid to be filtered. > So I created another dataview, which works fine, because now the filtering > of this second dataview does not affect the main form as its bound to the > first dataview. > > Where I'm stuck is that, once the user selects a record in the datagrid > which is bound to the second dataview, I want that particular record to be > displayed in the main form which is bound to the first dataview. > > and Cor, I did try this on the form, if I bound both the form & datagrid > to the same dataview (or a reference to it), you are right, the > currencymanager.position is in sync. and selecting one record, selects > the same in the other. But filtering one also filters the other, which I > don't want and so I tried with a second dataview, which can be filtered > independantly but now is not in sync. The only way its not in sync is > because it would have its own currencymanager isn't it? > > Thanks > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:us85kbjeHHA.4556@TK2MSFTNGP04.phx.gbl... >> Hemang, >>> >>> But both of these have their own currency manager (am I right here?) >>> >> No. >> >> Only if you create "new" dataviews. Otherwise they point to everything >> the same. In fact it are the defaultviews of the tables. >> >> In other words, all your controls binded to the same dataview or >> reference to that will have the same row as the currentrow >> >> This kind of things is easy to try by the way. >> >> Cor >> > > Cor,
I'm not asking how to create a new dataview. I've already done that. I want to sync the currencymanagers of the two dataview. Thanks Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:OpPcE1meHHA.208@TK2MSFTNGP05.phx.gbl... > Answer in C# > > Dataview dv = new DataView(TheTable); > > Cor > > "Hemang Shah" <hem***@hemang.net> schreef in bericht > news:%23Wg%23nojeHHA.1388@TK2MSFTNGP05.phx.gbl... >> Robin, Yes its the same issue, I posted it under a more meaningful >> heading, Thanks >> >> Cor, >> >> Maybe I was not clear in what I said. >> >> There are "two" different dataviews (not just one referencing the other) >> >> The reason I need two different dataview is because, all the controls on >> the form are bound to the first dataview. >> >> I want to display a datagrid which the user can filter by some criteria, >> If I use the same dataview for this then the records on the main form are >> filtered too. I dont want that. I want only the datagrid to be >> filtered. So I created another dataview, which works fine, because now >> the filtering of this second dataview does not affect the main form as >> its bound to the first dataview. >> >> Where I'm stuck is that, once the user selects a record in the datagrid >> which is bound to the second dataview, I want that particular record to >> be displayed in the main form which is bound to the first dataview. >> >> and Cor, I did try this on the form, if I bound both the form & datagrid >> to the same dataview (or a reference to it), you are right, the >> currencymanager.position is in sync. and selecting one record, selects >> the same in the other. But filtering one also filters the other, which I >> don't want and so I tried with a second dataview, which can be filtered >> independantly but now is not in sync. The only way its not in sync is >> because it would have its own currencymanager isn't it? >> >> Thanks >> >> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message >> news:us85kbjeHHA.4556@TK2MSFTNGP04.phx.gbl... >>> Hemang, >>>> >>>> But both of these have their own currency manager (am I right here?) >>>> >>> No. >>> >>> Only if you create "new" dataviews. Otherwise they point to everything >>> the same. In fact it are the defaultviews of the tables. >>> >>> In other words, all your controls binded to the same dataview or >>> reference to that will have the same row as the currentrow >>> >>> This kind of things is easy to try by the way. >>> >>> Cor >>> >> >> > > Show us than how you build those.
Cor Show quoteHide quote "Hemang Shah" <hem***@hemang.net> schreef in bericht news:usq1y3meHHA.4032@TK2MSFTNGP02.phx.gbl... > Cor, > > I'm not asking how to create a new dataview. > > I've already done that. > > I want to sync the currencymanagers of the two dataview. > > Thanks > > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:OpPcE1meHHA.208@TK2MSFTNGP05.phx.gbl... >> Answer in C# >> >> Dataview dv = new DataView(TheTable); >> >> Cor >> >> "Hemang Shah" <hem***@hemang.net> schreef in bericht >> news:%23Wg%23nojeHHA.1388@TK2MSFTNGP05.phx.gbl... >>> Robin, Yes its the same issue, I posted it under a more meaningful >>> heading, Thanks >>> >>> Cor, >>> >>> Maybe I was not clear in what I said. >>> >>> There are "two" different dataviews (not just one referencing the other) >>> >>> The reason I need two different dataview is because, all the controls on >>> the form are bound to the first dataview. >>> >>> I want to display a datagrid which the user can filter by some criteria, >>> If I use the same dataview for this then the records on the main form >>> are filtered too. I dont want that. I want only the datagrid to be >>> filtered. So I created another dataview, which works fine, because now >>> the filtering of this second dataview does not affect the main form as >>> its bound to the first dataview. >>> >>> Where I'm stuck is that, once the user selects a record in the datagrid >>> which is bound to the second dataview, I want that particular record to >>> be displayed in the main form which is bound to the first dataview. >>> >>> and Cor, I did try this on the form, if I bound both the form & datagrid >>> to the same dataview (or a reference to it), you are right, the >>> currencymanager.position is in sync. and selecting one record, selects >>> the same in the other. But filtering one also filters the other, which >>> I don't want and so I tried with a second dataview, which can be >>> filtered independantly but now is not in sync. The only way its not in >>> sync is because it would have its own currencymanager isn't it? >>> >>> Thanks >>> >>> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message >>> news:us85kbjeHHA.4556@TK2MSFTNGP04.phx.gbl... >>>> Hemang, >>>>> >>>>> But both of these have their own currency manager (am I right here?) >>>>> >>>> No. >>>> >>>> Only if you create "new" dataviews. Otherwise they point to everything >>>> the same. In fact it are the defaultviews of the tables. >>>> >>>> In other words, all your controls binded to the same dataview or >>>> reference to that will have the same row as the currentrow >>>> >>>> This kind of things is easy to try by the way. >>>> >>>> Cor >>>> >>> >>> >> >> > > In the GUI, I made a copy of dvClient (my original dataview), here is the
code that VS generated: I'll paste in code for the second dataview. public System.Data.DataView dvClient; (the original dataview bound to the main form) public DataView dvForSearch; (the new dataview I created for the datagrid) this.dvForSearch = new System.Data.DataView(); ((System.ComponentModel.ISupportInitialize)(this.dvForSearch)).BeginInit(); // // dvForSearch // this.dvForSearch.Sort = "GivenName"; this.dvForSearch.Table = this.dsClient.tblClient; this.dataGridView1.DataSource = this.dvForSearch; ((System.ComponentModel.ISupportInitialize)(this.dvForSearch)).EndInit(); Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:OoTE7epeHHA.1220@TK2MSFTNGP03.phx.gbl... > Show us than how you build those. > > Cor > > "Hemang Shah" <hem***@hemang.net> schreef in bericht > news:usq1y3meHHA.4032@TK2MSFTNGP02.phx.gbl... >> Cor, >> >> I'm not asking how to create a new dataview. >> >> I've already done that. >> >> I want to sync the currencymanagers of the two dataview. >> >> Thanks >> >> >> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message >> news:OpPcE1meHHA.208@TK2MSFTNGP05.phx.gbl... >>> Answer in C# >>> >>> Dataview dv = new DataView(TheTable); >>> >>> Cor >>> >>> "Hemang Shah" <hem***@hemang.net> schreef in bericht >>> news:%23Wg%23nojeHHA.1388@TK2MSFTNGP05.phx.gbl... >>>> Robin, Yes its the same issue, I posted it under a more meaningful >>>> heading, Thanks >>>> >>>> Cor, >>>> >>>> Maybe I was not clear in what I said. >>>> >>>> There are "two" different dataviews (not just one referencing the >>>> other) >>>> >>>> The reason I need two different dataview is because, all the controls >>>> on the form are bound to the first dataview. >>>> >>>> I want to display a datagrid which the user can filter by some >>>> criteria, If I use the same dataview for this then the records on the >>>> main form are filtered too. I dont want that. I want only the >>>> datagrid to be filtered. So I created another dataview, which works >>>> fine, because now the filtering of this second dataview does not affect >>>> the main form as its bound to the first dataview. >>>> >>>> Where I'm stuck is that, once the user selects a record in the datagrid >>>> which is bound to the second dataview, I want that particular record to >>>> be displayed in the main form which is bound to the first dataview. >>>> >>>> and Cor, I did try this on the form, if I bound both the form & >>>> datagrid to the same dataview (or a reference to it), you are right, >>>> the currencymanager.position is in sync. and selecting one record, >>>> selects the same in the other. But filtering one also filters the >>>> other, which I don't want and so I tried with a second dataview, which >>>> can be filtered independantly but now is not in sync. The only way its >>>> not in sync is because it would have its own currencymanager isn't it? >>>> >>>> Thanks >>>> >>>> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message >>>> news:us85kbjeHHA.4556@TK2MSFTNGP04.phx.gbl... >>>>> Hemang, >>>>>> >>>>>> But both of these have their own currency manager (am I right here?) >>>>>> >>>>> No. >>>>> >>>>> Only if you create "new" dataviews. Otherwise they point to everything >>>>> the same. In fact it are the defaultviews of the tables. >>>>> >>>>> In other words, all your controls binded to the same dataview or >>>>> reference to that will have the same row as the currentrow >>>>> >>>>> This kind of things is easy to try by the way. >>>>> >>>>> Cor >>>>> >>>> >>>> >>> >>> >> >> > > Hemang,
Can you try this piece of code with 3 datagridviews on the fomr private void Form1_Load(object sender, EventArgs e) { DataTable DT = new DataTable(); DataColumn DC1 = new DataColumn("One"); DataColumn DC2 = new DataColumn("Two"); DT.Columns.Add(DC1); DT.Columns.Add(DC2); DT.LoadDataRow(new object[] {"Hemang","Shah"},true); DT.LoadDataRow(new object[] {"Cor","Ligthert"},true); DataView DV1 = new DataView(DT); DataView DV2 = new DataView(DT); DataView DV3 = DV1; DV1.Sort = "One Desc"; DV2.Sort = "One Asc"; DV3.Sort = "One Asc"; dataGridView1.DataSource = DV1; dataGridView2.DataSource = DV2; dataGridView3.DataSource = DV3; } Cor
Other interesting topics
copying an object by value
Performance problems with OracleDataReader Connection string / design question Increase Connection\ Command timeout globally Adding a non unique index to a datatable adding a column to a table Multiple relation in dataset. RichText in asp.net Yet another designer issue Dataadapter and where clause. |
|||||||||||||||||||||||