|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Datagrids (again)A scenario has come up in which I'm not sure how to handle. What is happening is the user enters information in a cell of the grid. If the user then quits the application as soon as he finishes entering the data, the data entered in the cell is not saved. I have the following code in the closing event of the form: If DataSet.HasChanges Then Try DataAdapter.Update(DataSet.GetChanges, "Table") DataSet.AcceptChanges() Catch e As Exception MsgBox(e.message) Exit Sub End Try End If However, if the user tabs to the next cell, the data is saved. Is there something that can be done to save the data without having to tell the users that they must tab from the cell upon entering data? I tried replicating a tab key press (SendKeys.Send("{Tab}")) before updating but this did not fix it. Thanks a lot for the past and future help! Mike. Mike,
I have given you an aswer on this standard question some days ago in this newsgroup. Cor <mfleet1***@yahoo.ca> schreef in bericht Show quoteHide quote news:1153328333.053677.25740@m73g2000cwd.googlegroups.com... > Hi. > > A scenario has come up in which I'm not sure how to handle. What is > happening is the user enters information in a cell of the grid. If the > user then quits the application as soon as he finishes entering the > data, the data entered in the cell is not saved. I have the following > code in the closing event of the form: > > If DataSet.HasChanges Then > Try > DataAdapter.Update(DataSet.GetChanges, "Table") > DataSet.AcceptChanges() > Catch e As Exception > MsgBox(e.message) > Exit Sub > End Try > End If > > However, if the user tabs to the next cell, the data is saved. Is > there something that can be done to save the data without having to > tell the users that they must tab from the cell upon entering data? I > tried replicating a tab key press (SendKeys.Send("{Tab}")) before > updating but this did not fix it. > > Thanks a lot for the past and future help! > > Mike. > Hi Cor.
Actually the last datagrid post I did was concerning visual controls that were not in the grid but were pointing to the same record. The solution was to call EndCurrentEdit of the currencymanager which fixed the problem. This issue involves changes that are done within a cell in a grid. User enters data in the cell, never tabbing to the next cell, and then quits the app which triggers saving to the db. The changes are not saved. I tried calling EndCurrentEdit but that did not fix the problem. Thanks! Cor Ligthert [MVP] wrote: Show quoteHide quote > Mike, > > I have given you an aswer on this standard question some days ago in this > newsgroup. > > Cor > > <mfleet1***@yahoo.ca> schreef in bericht > news:1153328333.053677.25740@m73g2000cwd.googlegroups.com... > > Hi. > > > > A scenario has come up in which I'm not sure how to handle. What is > > happening is the user enters information in a cell of the grid. If the > > user then quits the application as soon as he finishes entering the > > data, the data entered in the cell is not saved. I have the following > > code in the closing event of the form: > > > > If DataSet.HasChanges Then > > Try > > DataAdapter.Update(DataSet.GetChanges, "Table") > > DataSet.AcceptChanges() > > Catch e As Exception > > MsgBox(e.message) > > Exit Sub > > End Try > > End If > > > > However, if the user tabs to the next cell, the data is saved. Is > > there something that can be done to save the data without having to > > tell the users that they must tab from the cell upon entering data? I > > tried replicating a tab key press (SendKeys.Send("{Tab}")) before > > updating but this did not fix it. > > > > Thanks a lot for the past and future help! > > > > Mike. > > so,
if i understand correctly, the user makes changes in a cell ... than exits the application - presses the close button on the window control bar ... the data is not changed in the dataadapter because the cell did not lose focus and the change is not ackonwledged ... in the closing event, get the current cell with focus and set the focus to the next cell ... force a tab or something ... or set focus to another control on the window ... anything to move the cursor / focus out of the curent cell ... this should force the data change to be acknowledge and the EndCurrentEdit should work...and thus the update to save the data ... <mfleet1***@yahoo.ca> wrote in message Show quoteHide quote news:1153330154.842194.171560@i42g2000cwa.googlegroups.com... > Hi Cor. > > Actually the last datagrid post I did was concerning visual controls > that were not in the grid but were pointing to the same record. The > solution was to call EndCurrentEdit of the currencymanager which fixed > the problem. > > This issue involves changes that are done within a cell in a grid. > User enters data in the cell, never tabbing to the next cell, and then > quits the app which triggers saving to the db. The changes are not > saved. I tried calling EndCurrentEdit but that did not fix the > problem. > > Thanks! > > Cor Ligthert [MVP] wrote: >> Mike, >> >> I have given you an aswer on this standard question some days ago in this >> newsgroup. >> >> Cor >> >> <mfleet1***@yahoo.ca> schreef in bericht >> news:1153328333.053677.25740@m73g2000cwd.googlegroups.com... >> > Hi. >> > >> > A scenario has come up in which I'm not sure how to handle. What is >> > happening is the user enters information in a cell of the grid. If the >> > user then quits the application as soon as he finishes entering the >> > data, the data entered in the cell is not saved. I have the following >> > code in the closing event of the form: >> > >> > If DataSet.HasChanges Then >> > Try >> > DataAdapter.Update(DataSet.GetChanges, "Table") >> > DataSet.AcceptChanges() >> > Catch e As Exception >> > MsgBox(e.message) >> > Exit Sub >> > End Try >> > End If >> > >> > However, if the user tabs to the next cell, the data is saved. Is >> > there something that can be done to save the data without having to >> > tell the users that they must tab from the cell upon entering data? I >> > tried replicating a tab key press (SendKeys.Send("{Tab}")) before >> > updating but this did not fix it. >> > >> > Thanks a lot for the past and future help! >> > >> > Mike. >> > > On validating of the grid control throw a boolean variable "IsDirty"
and on closing of the form: If IsDirty then If MsgBox("You have unsaved changes. Would you like to save your changes now?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then e.Cancel = True End If jeff wrote: Show quoteHide quote > so, > > if i understand correctly, the user makes changes in a cell ... than exits > the application - presses the close button on the window control bar ... the > data is not changed in the dataadapter because the cell did not lose focus > and the change is not ackonwledged ... > > in the closing event, get the current cell with focus and set the focus to > the next cell ... force a tab or something ... or set focus to another > control on the window ... anything to move the cursor / focus out of the > curent cell ... this should force the data change to be acknowledge and the > EndCurrentEdit should work...and thus the update to save the data ... > > > > <mfleet1***@yahoo.ca> wrote in message > news:1153330154.842194.171560@i42g2000cwa.googlegroups.com... > > Hi Cor. > > > > Actually the last datagrid post I did was concerning visual controls > > that were not in the grid but were pointing to the same record. The > > solution was to call EndCurrentEdit of the currencymanager which fixed > > the problem. > > > > This issue involves changes that are done within a cell in a grid. > > User enters data in the cell, never tabbing to the next cell, and then > > quits the app which triggers saving to the db. The changes are not > > saved. I tried calling EndCurrentEdit but that did not fix the > > problem. > > > > Thanks! > > > > Cor Ligthert [MVP] wrote: > >> Mike, > >> > >> I have given you an aswer on this standard question some days ago in this > >> newsgroup. > >> > >> Cor > >> > >> <mfleet1***@yahoo.ca> schreef in bericht > >> news:1153328333.053677.25740@m73g2000cwd.googlegroups.com... > >> > Hi. > >> > > >> > A scenario has come up in which I'm not sure how to handle. What is > >> > happening is the user enters information in a cell of the grid. If the > >> > user then quits the application as soon as he finishes entering the > >> > data, the data entered in the cell is not saved. I have the following > >> > code in the closing event of the form: > >> > > >> > If DataSet.HasChanges Then > >> > Try > >> > DataAdapter.Update(DataSet.GetChanges, "Table") > >> > DataSet.AcceptChanges() > >> > Catch e As Exception > >> > MsgBox(e.message) > >> > Exit Sub > >> > End Try > >> > End If > >> > > >> > However, if the user tabs to the next cell, the data is saved. Is > >> > there something that can be done to save the data without having to > >> > tell the users that they must tab from the cell upon entering data? I > >> > tried replicating a tab key press (SendKeys.Send("{Tab}")) before > >> > updating but this did not fix it. > >> > > >> > Thanks a lot for the past and future help! > >> > > >> > Mike. > >> > > > Mike,
Simple, Don't start with this, a datagrid has in front a little pencil to acknowledge the editing, so let the user do that. You are now building an application that is not working confirm the standards of that control. Just my thought, Cor <mfleet1***@yahoo.ca> schreef in bericht Show quoteHide quote news:1153328333.053677.25740@m73g2000cwd.googlegroups.com... > Hi. > > A scenario has come up in which I'm not sure how to handle. What is > happening is the user enters information in a cell of the grid. If the > user then quits the application as soon as he finishes entering the > data, the data entered in the cell is not saved. I have the following > code in the closing event of the form: > > If DataSet.HasChanges Then > Try > DataAdapter.Update(DataSet.GetChanges, "Table") > DataSet.AcceptChanges() > Catch e As Exception > MsgBox(e.message) > Exit Sub > End Try > End If > > However, if the user tabs to the next cell, the data is saved. Is > there something that can be done to save the data without having to > tell the users that they must tab from the cell upon entering data? I > tried replicating a tab key press (SendKeys.Send("{Tab}")) before > updating but this did not fix it. > > Thanks a lot for the past and future help! > > Mike. > Have you stepped through to see if the .HasChanges is returning as true?
I'm guessing here, but maybe the change to the cell in the datagrid isn't making the change to the DataSet until after the cell loses focus. Also I don't think the .AcceptChanges is necessary as calling the DataAdapter.Update should set all rowstates to unchanged. <mfleet1***@yahoo.ca> wrote in message Show quoteHide quote news:1153328333.053677.25740@m73g2000cwd.googlegroups.com... > Hi. > > A scenario has come up in which I'm not sure how to handle. What is > happening is the user enters information in a cell of the grid. If the > user then quits the application as soon as he finishes entering the > data, the data entered in the cell is not saved. I have the following > code in the closing event of the form: > > If DataSet.HasChanges Then > Try > DataAdapter.Update(DataSet.GetChanges, "Table") > DataSet.AcceptChanges() > Catch e As Exception > MsgBox(e.message) > Exit Sub > End Try > End If > > However, if the user tabs to the next cell, the data is saved. Is > there something that can be done to save the data without having to > tell the users that they must tab from the cell upon entering data? I > tried replicating a tab key press (SendKeys.Send("{Tab}")) before > updating but this did not fix it. > > Thanks a lot for the past and future help! > > Mike. >
disabling checkbox in checkedlistbox
Argument not specified check database connection/open Access Databse "Select * from Bilag Where Mdates Between #1/1/2006# And #31/1/2006#" ComboBox SelectionChangeCommitted event fires twice VB6 to VB.NET Create Recordset from a non standard data source Crystal Reports and Data Tables. TreeView Nodes and Icons Property: ReadOnly on public scope while Read-Write on friend or private scope |
|||||||||||||||||||||||