GrapeCity MultiRow Windows Forms Documentation
Refer to Editing Value when Modifying TrueValue and FalseValue (CheckBoxCell)

You can use the Cell.EditedFormattedValue property for the check box cell and get the cell value being edited; however, if you are editing the TrueValue and FalseValue properties in the check box cell, then its value cannot be returned by the CheckBoxCell.EditedFormattedValue property. This is because the CheckBoxCell.EditedFormattedValue property is formatted using the CheckBoxCell.FormattedValueType type. To refer to the value of the TrueValue and FalseValue properties of the check box cell, you can directly refer to the respective property based on the value in the CheckBoxCell.EditedFormattedValue property.

Using Code

This example creates a check box cell and gets the value being edited.

[VB]

Imports GrapeCity.Win.MultiRow

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim checkBoxCell1 As New CheckBoxCell()
    checkBoxCell1.TrueValue = "Yes"
    checkBoxCell1.FalseValue = "No"
    GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() {checkBoxCell1})
End Sub

Private Sub GcMultiRow1_CellEditedFormattedValueChanged(ByVal sender As System.Object, ByVal e As GrapeCity.Win.MultiRow.CellEditedFormattedValueChangedEventArgs) Handles GcMultiRow1.CellEditedFormattedValueChanged
    Dim gcMultiRow As GcMultiRow = TryCast(sender, GcMultiRow)
    Dim currentCell As Cell = gcMultiRow.Rows(e.RowIndex).Cells(e.CellIndex)
    
    If currentCell.IsInEditMode Then
        If TypeOf currentCell Is CheckBoxCell Then
            Dim checkBoxCell1 As CheckBoxCell = TryCast(currentCell, CheckBoxCell)
            If DirectCast(checkBoxCell1.EditedFormattedValue, Boolean) Then
                Console.WriteLine(checkBoxCell1.TrueValue)
            Else
                 Console.WriteLine(checkBoxCell1.FalseValue)
            End If
        End If
    End If
End Sub

[CS]

using GrapeCity.Win.MultiRow;

private void Form1_Load(object sender, EventArgs e)
{
    CheckBoxCell checkBoxCell1 = new CheckBoxCell();
    checkBoxCell1.TrueValue = "Yes";
    checkBoxCell1.FalseValue = "No";
    gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { checkBoxCell1 });
    
    gcMultiRow1.CellEditedFormattedValueChanged += new EventHandler<CellEditedFormattedValueChangedEventArgs>(gcMultiRow1_CellEditedFormattedValueChanged);
}

private void gcMultiRow1_CellEditedFormattedValueChanged(object sender, CellEditedFormattedValueChangedEventArgs e)
{
    GcMultiRow gcMultiRow = sender as GcMultiRow;
    Cell currentCell = gcMultiRow.Rows[e.RowIndex].Cells[e.CellIndex];
    
    if (currentCell.IsInEditMode)
    {
        if (currentCell is CheckBoxCell)
        {
            CheckBoxCell checkBoxCell1 = currentCell as CheckBoxCell;
            if ((bool)checkBoxCell1.EditedFormattedValue)
            {
                 Console.WriteLine(checkBoxCell1.TrueValue);
            }
            else
            {
                Console.WriteLine(checkBoxCell1.FalseValue);
             }
        }
    }
}
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options