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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

12456 Mar 30,2004 07:01 PM Mar 31,2004 09:37 AM Windows Forms 3
loading
Tags: GridControl
simon
Asked On March 30, 2004 07:01 PM

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 03:38 AM

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

simon
Replied On March 31, 2004 08:55 AM

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 09:37 AM

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.

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.

;