Windows Developer Center > Windows Forms Forums > Windows Forms Data Controls and Databinding > invalidoperationexception -cannot commit or quit a cell value change
Ask a questionAsk a question
 

Answerinvalidoperationexception -cannot commit or quit a cell value change

  • Monday, October 01, 2007 8:50 AMcl0306 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     


    I get the following invalidoperationexception:
    Operation did not succeed because the program cannot commit or quit a cell value change.

    raised when I try to add a UserControl to a Panel. The UserControl in question has already been initialized and contains a DataGridView which has already been bound to a datasource.

    To try to resolve I have tried making the cells readonly and have also set AllowUserToAddRows to false.

    Any ideas on what else to try?

    Regards,

    Chris.

Answers

  • Monday, October 01, 2007 9:44 AMfranking Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi Chris,

     

    please try to post some code so we can have a little closer look at the problem. Or any more detail about the control might be helpful.

     

    If your're using BindingSource as datasource for your datagridview, try to set the RaiseListChangeEvents property to false before adding the control to the panel and change it back to true afterwards.

     

    Hope this helps.

    franking

     

All Replies

  • Monday, October 01, 2007 9:44 AMfranking Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi Chris,

     

    please try to post some code so we can have a little closer look at the problem. Or any more detail about the control might be helpful.

     

    If your're using BindingSource as datasource for your datagridview, try to set the RaiseListChangeEvents property to false before adding the control to the panel and change it back to true afterwards.

     

    Hope this helps.

    franking

     

  • Monday, October 01, 2007 11:09 AMcl0306 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Thanks franking,

     

    using a bindingsource as the datasource worked!  Didnt need to set RaiseListChangeEvents to false.

     

    I think the problem might have been related to the fact that I was using a BindingList<T> as the datasource.

     

    Cheers!