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

Updating GridViewCheckBoxColumn value on another column's change

3 Answers 246 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Philippe
Top achievements
Rank 2
Philippe asked on 26 Oct 2012, 03:41 PM
Hello

I have a GridViewCheckBoxColumn column added to a GridView that serves as a visual flag about the row's update status. I want to validate and update that checkbox' ToggleState while I am in the CellEndEdit of another column (that have a Spinner editor).

This gives me a Null value on the left side. (as well as many variants thereof)

if ((ToggleState)e.Row.Cells["RegleActive"].Value == ToggleState.On)

Thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 31 Oct 2012, 11:03 AM
Hello Phillippe,

Thank you for writing.

In my tests, the value of the cell is not null and I have no problems accessing it from the EndEdit event handler triggered for a decimal column edit. Here is a sample application:
public partial class Form1 : Form
   {
       public Form1()
       {
           InitializeComponent();
 
           radGridView1.Columns.Add(new GridViewCheckBoxColumn("check"));
           radGridView1.Columns.Add(new GridViewDecimalColumn("number"));
           radGridView1.Rows.Add(true, 10);
           radGridView1.Rows.Add(false, 10);
           radGridView1.Rows.Add(null, 10);
 
           radGridView1.CellEndEdit += radGridView1_CellEndEdit;
 
       }
 
       void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
       {
           RadMessageBox.Show("the check box value is: " + Convert.ToBoolean(e.Row.Cells["check"].Value));
       }
   }

If you continue experiencing this behavior, please open a new support ticket where you can attach a sample project demonstrating the issue. Once we get it we will investigate it and we will get back to you with the results.
 
Regards,
Stefan
the Telerik team
Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Philippe
Top achievements
Rank 2
answered on 31 Oct 2012, 12:13 PM
I found my error yesterday late at night. The Checkbox column is unbound, and when I initialized the values in it, I only set the checked values, not the unchecked ones. Thoses where the ones that where giving me Null errors.
foreach (GridViewRowInfo row in radGridSKU.Rows) // Boucler toutes les lignes pour mettre le checkbox correctement
            {
                if (row.Cells["ForceeClient"].Value.ToString() != "0")
                {
                    row.Cells["RegleActive"].Value = ToggleState.On;
                    row.Cells["RegleActive"].ReadOnly = false;
                }
                else
                {
                    row.Cells["RegleActive"].Value = ToggleState.Off; // <= That's the line I forgot to put in
                    row.Cells["RegleActive"].ReadOnly = true;
                }
            }

Thanks for your time
-Philippe
0
Stefan
Telerik team
answered on 02 Nov 2012, 12:51 PM
Hello,

It is great to hear that everything is OK now. Should you have any other questions, do not hesitate to contact us.
 
All the best,
Stefan
the Telerik team
Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
GridView
Asked by
Philippe
Top achievements
Rank 2
Answers by
Stefan
Telerik team
Philippe
Top achievements
Rank 2
Share this question
or