We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Accepting changes in a datagrid (not as dumb as it sounds)

Thread ID:

Created:

Updated:

Platform:

Replies:

12456 Mar 31,2004 12:01 AM UTC Mar 31,2004 02:37 PM UTC WinForms 3
loading
Tags: GridControl
simon
Asked On March 31, 2004 12:01 AM UTC

I have a grid displaying URLS and an ''Add New'' button When i click the button a new row is added. Now if i''m editing a row and i click the button, then the grid loses focus which means it saves the current row and then the New button adds a new entry. I also have the ability to drag in a URL from internet explorer which calls the AddNew() method. BUT since the focus is not lost on the grid then whatever changes you were making are lost. So i tried this : private void AcceptChanges(GridDataBoundGrid grid) { // if we drag a URL in then the data doesnt get updates unless we do this DataView dv = (DataView) grid.DataSource; CurrencyManager cm = (CurrencyManager)this.BindingContext[dv]; cm.EndCurrentEdit(); } I also tried private void AcceptChanges(GridDataBoundGrid grid) { // if we drag a URL in then the data doesnt get updates unless we do this DataView dv = (DataView) grid.DataSource; CurrencyManager cm = (CurrencyManager)this.BindingContext[dv]; ((DataRowView) cm.Current).Row.AcceptChanges(); } the currency manager correctly identifies the row i''m editing, but cm.EndCurrentEdit() does not save the data in the row. How do i do this? There

Administrator [Syncfusion]
Replied On March 31, 2004 08:38 AM UTC

Try first calling grid.CurrenctCell.EndEdit() and then grid.Binder.EndEdit() (or your currencymanager.EndCurrentEdit())

simon
Replied On March 31, 2004 01:55 PM UTC

thanks, that did it is it safe to call these methods if there is no CurrentCell. i got no null reference exception so i assume it is

Administrator [Syncfusion]
Replied On March 31, 2004 02:37 PM UTC

It is OK. The EndEdit method has embbedded checks to avoid problems.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;