RE: CancelCurrentEdit doesn't

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thanks Kevin

I see the problem now. Changing rows in the datagrid calls an endedit on the
current row.

I have a Save and Cancel button on the form containing the datagrids. I am
working in a completely disconnected dataset so acceptchanges etc. are of no
use.

There is no table wide canceledit or endedit so I guess the only way to save
or cancel all the changes made to a bound datagrid is to make a copy of the
table and restore in on cancel. Is this the recommended method?


--
Many Thanks
Terry


"Kevin Yu [MSFT]" wrote:

> Hi Terry,
>
> First of all, I would like to confirm my understanding of your issue. From
> your description, I understand that when you bind 3 DataViews from the same
> DataTable to DataGrids, the changed data is not synchronized, and the
> CancelCurrentEdit doesn't work. If there is any misunderstanding, please
> feel free to let me know.
>
> I checked your code, but didn't find anything wrong. I wrote a similar
> project on my machine and it works fine for me. Would you try the following
> code which connects to the Employee table in Northwind database.
>
> Private cm1 As CurrencyManager
> Private cm2 As CurrencyManager
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Dim ds As New DataSet
> Me.SqlDataAdapter1.Fill(ds)
>
> Dim dv1 As New DataView(ds.Tables(0))
> dv1.RowFilter = "Title='Sales Representative'"
> Dim dv2 As New DataView(ds.Tables(0))
> dv2.RowFilter = "TitleOfCourtesy='Mr.'"
>
> Me.DataGrid1.DataSource = dv1
> Me.DataGrid2.DataSource = dv2
>
> Me.cm1 = CType(Me.BindingContext(dv1), CurrencyManager)
> Me.cm2 = CType(Me.BindingContext(dv2), CurrencyManager)
> End Sub
>
> Private Sub DataGrid1_KeyUp(ByVal sender As Object, ByVal e As
> System.Windows.Forms.KeyEventArgs) Handles DataGrid1.KeyUp
> If e.KeyCode = Keys.Escape Then
> Me.cm1.CancelCurrentEdit()
> End If
> End Sub
>
> You can try to modify your app according to this code snippet. HTH.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>
>
.


Quantcast