CurrentCellDirtyStateChanged Event

7 posts, 0 answers
  1. Burt
    Burt avatar
    5 posts
    Member since:
    Jul 2012

    Posted 10 May 2012 Link to this post

    Is there anyway to replicate this event in a RadGridView? I relied on this heavily for pushing user "checks" (CheckBoxCells) to the database with the standard DataGridView control, and I couldn't find anything similar with the RadControls. Here is a sample of what I would do with the event:

    void dataGridView_CurrentCellDirtyStateChanged(object  sender, EventArgs  e)
    {       
         if ((dataGridView.IsCurrentCellDirty) & (dataGridView.CurrentCell.ColumnIndex == 0))
         {
              dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
         }
    }
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 15 May 2012 Link to this post

    Hello Burt,

    Thank you for writing.

    You can try the ValueChaged event of RadGridView to achieve this functionality. The event is raised when the value is changed in the active editor of RadGridView, but the change is not yet committed to the row cache or the underline object in bound mode.

    I hope this information is helpful. Let me know if you need further assistance.

    Regards,
    Julian Benkov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. Burt
    Burt avatar
    5 posts
    Member since:
    Jul 2012

    Posted 15 May 2012 Link to this post

    Hi Julian,

    Then how do you commit the change to the row cache, as you said? The "CommitEdit" property does not exist in the RadGridView.

    The ValueChanged event is nice, but it took a lot of work just to get anything useful out of this event, cause the arguments were the system defaults and provided me with nothing:

    private void radGridView1_ValueChanged(System::Object^  sender, System::EventArgs^  e) {
    // checks if the type of cell was a checkbox
    if(sender->GetType()->ToString()->Contains("RadCheckBoxEditor"))
    {
      RadCheckBoxEditor^ rad_chb = (RadCheckBoxEditor^)sender;
      GridCheckBoxCellElement^ checked_a_box = (GridCheckBoxCellElement^)rad_chb->OwnerElement;
      // Template name that the checkbox originated from
      checked_a_box->ViewTemplate->Caption;
      // Hidden cell that contains the top level row information
      checked_a_box->RowInfo->Cells[0]->Value->ToString();
     }
    }


    This is all the information I need to know exactly how to handle a click, but before, I could force the DataGrid to commit the changes and in turn it would fire the "CellValueChanged" event, which was especially handy since I already had the code in place to handle the change.
                   
  4. Burt
    Burt avatar
    5 posts
    Member since:
    Jul 2012

    Posted 15 May 2012 Link to this post

    This is how I ended up remedying this problem:

    This code is nasty, but it behaves similarly to my regular DataGridView method for committing to the grid, and subsequently the database since in my "CellValueChanged" handler I have SQL update statements

    private: System::Void radGridView1_ValueChanged(System::Object^  sender, System::EventArgs^  e) {
         
    if(sender->GetType()->ToString()->Contains("RadCheckBoxEditor"))
          {                      
              RadCheckBoxEditor^ rad_chb = (RadCheckBoxEditor^)sender;
              GridCheckBoxCellElement^ checked_a_box = (GridCheckBoxCellElement^)rad_chb->OwnerElement;
              checked_a_box->Value = rad_chb->Value;

              GridViewCellEventArgs^ new_args = gcnew GridViewCellEventArgs(checked_a_box->RowInfo, checked_a_box->ColumnInfo, checked_a_box->Editor);
              radGridView1_CellValueChanged(checked_a_box, new_args);
          }          
          else          
          {              
             
    return;            
          }
    }

  5. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 17 May 2012 Link to this post

    Hi Burt,

    I am glad to hear that you have solved your case. Feel free to contact us if you have any additional questions. 

    Kind regards,
    Julian Benkov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  6. Paruvathambal
    Paruvathambal avatar
    1 posts
    Member since:
    May 2018

    Posted 17 Sep 2018 Link to this post

    Hi Brut,

    checked_a_box->Value = rad_chb->Value;

    From the above line only it is firing the "radGridView1_CellValueChanged" event. But again why are you calling the same event.

    Please share me some working sample of "radGridView1_CellValueChanged" event, here you have given only "radGridView1_ValueChanged" event.

     

  7. Dimitar
    Admin
    Dimitar avatar
    2853 posts

    Posted 18 Sep 2018 Link to this post

    Hello Paruvathambal,

    This code seems to be an old solution. Now you can set the EditMode of the column and the CellValueChanged event will be fired immediately:
    var col = radGridView1.Columns[0] as GridViewCheckBoxColumn;
    col.EditMode = EditMode.OnValueChange;

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top