Welcome to the Xceed Community | Help
Community Search  
More Search Options

dataGridControl.EndEdit() does not end the edit state

Sort Posts: Previous Next
  •  03-12-2010, 5:47 AM Post no. 26086

    dataGridControl.EndEdit() does not end the edit state

    Hi, as I've already posted here http://xceed.com/CS/forums/thread/25907.aspx

    I've got a mayor problem with the XCeed Grid (version 3.2)!!

    I already spent several days of my live and am a little frustrated already... :-(

    The problem is as follows: When the user enters something in a grid cell and presses the "Save" - Button, he/she would certainly expect, that his changes will be saved. But they are not, because the edit state has not ended (IsBeingEdited = true) and so the datasource has has not been updated.

    The user will never figure out, that he has to hit the Enter-Key before pressing the Save-Button.

    I tried a lot of code to end the Edit State, but nothing worked....
    I still hope, that I forgot about something elementary....

    So my question is: Is there a working way to end the edit state with version 3.2?
    Alternative question: How can I simulate an ENTER-Keystroke?

    Regards,

     Helmut

     

     

     

    Filed under:
  •  03-12-2010, 6:47 AM Post no. 26087 in reply to 26086

    Re: dataGridControl.EndEdit() does not end the edit state

    I still use v3.2 and have created a base function which I can call to save or cancel and edit (I think this is what you are looking for):

        internal void CompleteTheEditingProcess(bool bAcceptChanges)
        {
          if (this.IsBeingEdited)
          {
            DataGridContext dgc = this.CurrentContext;
            if (dgc != null)
            {
         //Is the master or detail in edit mode. Done this way since if in Detail just calling
         //DataGridControl.EndEdit() causes exception
         if (dgc.ParentDataGridContext != null && dgc.ParentItem != null)
         {
          //If it is in the Detail row then select the parent (this stops an unhandled exception)
          this.CurrentItem = dgc.ParentItem;
          this.SelectedItem = dgc.ParentItem;
         }
         else if (ItemsSource != null)
         {
          //Only complete the edit process if the CurrentEditItem is not null
          DataGridCollectionView dgcv = this.ItemsSource as DataGridCollectionView;
          if (dgcv.CurrentEditItem != null)
          {
           if (bAcceptChanges)
           {
            dgc.EndEdit();
           }
           else
           {
            dgc.CancelEdit();
           }
          }
         }
            }
          }
        }

  •  03-18-2010, 4:59 AM Post no. 26180 in reply to 26087

    Re: dataGridControl.EndEdit() does not end the edit state

    Hmm, thanks for the reply

    but does not work for me, too.
    When I step through your code, I get

    dgcv.CurrentEditItem == null

    Hmm, could it be, I have to do something at the beginning of the edit process?

    What do you think?

  •  03-18-2010, 6:24 AM Post no. 26184 in reply to 26180

    Re: dataGridControl.EndEdit() does not end the edit state

    Buhhhhhh, ok I got it!!!!  (spent several days on this one)

    The problem was as follows:
    I've built a WPF user control, containing the dataGrid, that resides on a dialog window.
    When the user presses the SAVE button, I did Close() on the window.
    The closing of the window had a sideeffect on the EndEdit. Now I delayed the closing of the window and it works... :-)

    Thanks to all....

     

    P.S.: The real problem is, that I use this "Microsoft Technology" (.NET Framework, WPF, C#, Visual Studio, ....)
    Live was so easy and perfect two years ago with Borland Delphi. Software-Developement was rapid, easy, stable, fast and cheap (compared to now). Ok, C#/WPF is real progress compared to C++/MFC, but is is a big step back compared to Delphi/VCL, imho.

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.