This is a migrated thread and some comments may be shown as answers.

CurrentCellDirtyStateChanged Event

6 Answers 311 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Burt
Top achievements
Rank 1
Burt asked on 10 May 2012, 08:52 PM
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);
     }
}

6 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 15 May 2012, 11:52 AM
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 >>
0
Burt
Top achievements
Rank 1
answered on 15 May 2012, 06:05 PM
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.
               
0
Burt
Top achievements
Rank 1
answered on 15 May 2012, 08:12 PM
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;            
      }
}

0
Julian Benkov
Telerik team
answered on 17 May 2012, 02:16 PM
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 >>
0
Paruvathambal
Top achievements
Rank 1
answered on 18 Sep 2018, 04:45 AM

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.

 

0
Dimitar
Telerik team
answered on 18 Sep 2018, 06:46 AM
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.
Tags
GridView
Asked by
Burt
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Burt
Top achievements
Rank 1
Paruvathambal
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or