|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataRow Rowstate and drag and dropwindowsforms 1.1 Hi, I'm displaying a datagrid when the user enters (highlights) a certain text cell on a row it does a lookup of possible matches. The matches are displayed in a listbox and one of those matches can be quickly tossed with the mouse over to the grid surface and replace the original cell text. In the datagrids DragDrop event I'm using BeginEdit() EndEdit() on the Row where the change takes place. But this does not leave the DataSets Rowstate for that Row as Modified? I hoped to use the rowstate as a condition for updates (one or many) The grid works (Rowstate is correct) when the certain text cell that is the source of the lookup is keyboard edited or other grid type functions. How to solve? -- "it's definitely useless and maybe harmful". John,
Have a look in 1.1 to EndCurrentEdit. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscurrencymanagerclassendcurrentedittopic.asp AFAIK is this problem in 2.0 gone. I hope this helps, Cor Show quote "John Sitka" <johnsi***@REMOVEhotmail.com> schreef in bericht news:OWis$Y4RGHA.4456@TK2MSFTNGP14.phx.gbl... > crosspost but I have a feeling W.G. Ryan may know a trick. > > windowsforms 1.1 > > Hi, > > I'm displaying a datagrid > when the user enters (highlights) a certain text cell on a row it does a > lookup of possible matches. > The matches are displayed in a listbox and one of those matches can be > quickly tossed with the mouse > over to the grid surface and replace the original cell text. > > In the datagrids DragDrop event I'm using BeginEdit() EndEdit() on the Row > where the change takes place. > But this does not leave the DataSets Rowstate for that Row as Modified? > > I hoped to use the rowstate as a condition for updates (one or many) > > The grid works (Rowstate is correct) when the certain text cell that is > the source of the lookup is keyboard edited or other grid > type functions. > > How to solve? > > -- > "it's definitely useless and maybe harmful". > Cruel wicked fate.....
Tip 9: More Control Over RowState ADO.NET 2.0 provides two new methods to provide greater control over a DataRow's RowState: SetAdded and SetModified. These methods set the RowState property of a DataRow, which was a read-only property in ADO.NET 1.0. // Developer can use these to set the RowState // of an unchanged row oMyDataRow.SetAdded(); oMyDataRow.SetModified(); Yep,Here is what I have now.private void uxdgCadQuick_DragDrop(object sender, System.Windows.Forms.DragEventArgs e){//lastuxdgCadQuickClickRow,lastuxdgCadQuickClickCol are form class level fields that remember the special column cellDataGrid myGrid = (DataGrid)sender;DataGrid.HitTestInfo myHitInfo = myGrid.HitTest(e.X, e.Y);uxdgCadQuick[lastuxdgCadQuickClickRow,lastuxdgCadQuickClickCol] = e.Data.GetData(DataFormats.Text).ToString();dsCadQuick.Tables[0].Rows[lastuxdgCadQuickClickRow].BeginEdit();dsCadQuick.Tables[0].Rows[lastuxdgCadQuickClickRow]["partno"] = e.Data.GetData(DataFormats.Text).ToString();dsCadQuick.Tables[0].Rows[lastGridClickRow].EndEdit();uxdgCadQuick.SelectionBackColor.ToKnownColor(); }This works in that the Datagrid and Datatable DataRow exists with the changed infobut I can't go back say after a couple more edits and get the set of all rows inthat datatable and find which ones have changed and Update either via aDataAdapter or with my own Update commands.Thanks for the link, I don't get it yet though, but just started trying."Cor Ligthert [MVP]" Show quote <notmyfirstn***@planet.nl> wrote in message news:OPUHGD5RGHA.4384@tk2msftngp13.phx.gbl... > John, > > Have a look in 1.1 to EndCurrentEdit. > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscurrencymanagerclassendcurrentedittopic.asp > > AFAIK is this problem in 2.0 gone. > > I hope this helps, > > Cor > > "John Sitka" <johnsi***@REMOVEhotmail.com> schreef in bericht news:OWis$Y4RGHA.4456@TK2MSFTNGP14.phx.gbl... >> crosspost but I have a feeling W.G. Ryan may know a trick. >> >> windowsforms 1.1 >> >> Hi, >> >> I'm displaying a datagrid >> when the user enters (highlights) a certain text cell on a row it does a lookup of possible matches. >> The matches are displayed in a listbox and one of those matches can be quickly tossed with the mouse >> over to the grid surface and replace the original cell text. >> >> In the datagrids DragDrop event I'm using BeginEdit() EndEdit() on the Row where the change takes place. >> But this does not leave the DataSets Rowstate for that Row as Modified? >> >> I hoped to use the rowstate as a condition for updates (one or many) >> >> The grid works (Rowstate is correct) when the certain text cell that is the source of the lookup is keyboard edited or other grid >> type functions. >> >> How to solve? >> >> -- >> "it's definitely useless and maybe harmful". >> > > WOW crappy formatting...
Anyways is the gist of it to use this hunk from the link you provided CurrencyManager gridCurrencyManager = (CurrencyManager)this.BindingContext [dataGrid1.DataSource, dataGrid1.DataMember]; gridCurrencyManager.EndCurrentEdit(); as a replacement for DataSet.Tables[0].Rows[<the edited row>].EndEdit Reformatted..... Here is what I have now. private void uxdgCadQuick_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { //lastuxdgCadQuickClickRow,lastuxdgCadQuickClickCol are form class level fields that remember the special column cell DataGrid myGrid = (DataGrid)sender; DataGrid.HitTestInfo myHitInfo = myGrid.HitTest(e.X,e.Y); uxdgCadQuick[lastuxdgCadQuickClickRow,lastuxdgCadQuickClickCol] = e.Data.GetData(DataFormats.Text).ToString(); dsCadQuick.Tables[0].Rows[lastuxdgCadQuickClickRow].BeginEdit(); dsCadQuick.Tables[0].Rows[lastuxdgCadQuickClickRow]["partno"] = e.Data.GetData(DataFormats.Text).ToString(); dsCadQuick.Tables[0].Rows[lastGridClickRow].EndEdit(); uxdgCadQuick.SelectionBackColor.ToKnownColor(); } This works in that the Datagrid and Datatable DataRow exists with the changed infobut I can't go back say after a couple more edits and get the set of all rows inthat datatable and find which ones have changed and Update either via aDataAdapter or with my own Update commands.Thanks for the link, I don't get it yet though, but just started trying." Show quote "John Sitka" <johnsi***@REMOVEhotmail.com> wrote in message news:uQSBnV5RGHA.5656@TK2MSFTNGP11.phx.gbl... > Cruel wicked fate..... > > Tip 9: More Control Over RowState > ADO.NET 2.0 provides two new methods to provide greater control over a DataRow's RowState: SetAdded and SetModified. These methods > set the RowState property of a DataRow, which was a read-only property in ADO.NET 1.0. > > // Developer can use these to set the RowState > // of an unchanged row > oMyDataRow.SetAdded(); > oMyDataRow.SetModified(); > > Yep,Here is what I have now.private void uxdgCadQuick_DragDrop(object sender, System.Windows.Forms.DragEventArgs > e){//lastuxdgCadQuickClickRow,lastuxdgCadQuickClickCol are form class level fields that remember the special column cellDataGrid > myGrid = (DataGrid)sender;DataGrid.HitTestInfo myHitInfo = myGrid.HitTest(e.X, > e.Y);uxdgCadQuick[lastuxdgCadQuickClickRow,lastuxdgCadQuickClickCol] = > e.Data.GetData(DataFormats.Text).ToString();dsCadQuick.Tables[0].Rows[lastuxdgCadQuickClickRow].BeginEdit();dsCadQuick.Tables[0].Rows[lastuxdgCadQuickClickRow]["partno"] > = > e.Data.GetData(DataFormats.Text).ToString();dsCadQuick.Tables[0].Rows[lastGridClickRow].EndEdit();uxdgCadQuick.SelectionBackColor.ToKnownColor(); > }This works in that the Datagrid and Datatable DataRow exists with the changed infobut I can't go back say after a couple more > edits and get the set of all rows inthat datatable and find which ones have changed and Update either via aDataAdapter or with my > own Update commands.Thanks for the link, I don't get it yet though, but just started trying."Cor Ligthert [MVP]" > <notmyfirstn***@planet.nl> wrote in message news:OPUHGD5RGHA.4384@tk2msftngp13.phx.gbl... >> John, >> >> Have a look in 1.1 to EndCurrentEdit. >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscurrencymanagerclassendcurrentedittopic.asp >> >> AFAIK is this problem in 2.0 gone. >> >> I hope this helps, >> >> Cor >> >> "John Sitka" <johnsi***@REMOVEhotmail.com> schreef in bericht news:OWis$Y4RGHA.4456@TK2MSFTNGP14.phx.gbl... >>> crosspost but I have a feeling W.G. Ryan may know a trick. >>> >>> windowsforms 1.1 >>> >>> Hi, >>> >>> I'm displaying a datagrid >>> when the user enters (highlights) a certain text cell on a row it does a lookup of possible matches. >>> The matches are displayed in a listbox and one of those matches can be quickly tossed with the mouse >>> over to the grid surface and replace the original cell text. >>> >>> In the datagrids DragDrop event I'm using BeginEdit() EndEdit() on the Row where the change takes place. >>> But this does not leave the DataSets Rowstate for that Row as Modified? >>> >>> I hoped to use the rowstate as a condition for updates (one or many) >>> >>> The grid works (Rowstate is correct) when the certain text cell that is the source of the lookup is keyboard edited or other >>> grid >>> type functions. >>> >>> How to solve? >>> >>> -- >>> "it's definitely useless and maybe harmful". >>> >> >> > > Thanks.
The link you provided is an improvement and did address what I needed. basically CurrencyManager gridCurrencyManager = (CurrencyManager)this.BindingContext [dataGrid1.DataSource, dataGrid1.DataMember]; gridCurrencyManager.EndCurrentEdit(); is a replacement for DataSet.Tables[0].Rows[<the edited row>].EndEdit(); I still can't quite get things perfect because the Edit of the cell when generated by a DragDrop using DragDropEffects.Copy still dosen't explicitly drive the row editing events in a similar way as selecting a cell with a mouse of tabbing and editing cells with a keyboard. (pencil/arrow in row header) Thus after the Edit is made via DragandDrop the RowState is still not set to "modified" until the DataGrid row is changed by some GUI event, and I can't seem to find the navigation technique to an available "parked" position in a Datagrid which drives that RowState commitment. Thanks again. Cor Ligthert [MVP] Show quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:OPUHGD5RGHA.4384@tk2msftngp13.phx.gbl... > John, > > Have a look in 1.1 to EndCurrentEdit. > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscurrencymanagerclassendcurrentedittopic.asp > > AFAIK is this problem in 2.0 gone. > > I hope this helps, > > Cor > > "John Sitka" <johnsi***@REMOVEhotmail.com> schreef in bericht news:OWis$Y4RGHA.4456@TK2MSFTNGP14.phx.gbl... >> crosspost but I have a feeling W.G. Ryan may know a trick. >> >> windowsforms 1.1 >> >> Hi, >> >> I'm displaying a datagrid >> when the user enters (highlights) a certain text cell on a row it does a lookup of possible matches. >> The matches are displayed in a listbox and one of those matches can be quickly tossed with the mouse >> over to the grid surface and replace the original cell text. >> >> In the datagrids DragDrop event I'm using BeginEdit() EndEdit() on the Row where the change takes place. >> But this does not leave the DataSets Rowstate for that Row as Modified? >> >> I hoped to use the rowstate as a condition for updates (one or many) >> >> The grid works (Rowstate is correct) when the certain text cell that is the source of the lookup is keyboard edited or other grid >> type functions. >> >> How to solve? >> >> -- >> "it's definitely useless and maybe harmful". >> > > |
|||||||||||||||||||||||