GrapeCity MultiRow Windows Forms Documentation
CellValuePushed Event
Example 


Occurs when the VirtualMode property of a GcMultiRow control is true and a cell value has changed which requires storage in the underlying data source.
Syntax
<SRCategoryAttribute("Data")>
<SRDescriptionAttribute("Occurs when the VirtualMode property of the GcMultiRow control is true and a cell value has changed and requires storage in the underlying data source.")>
<FeatureAttribute(Name="VirtualMode", Version="v5.0")>
Public Event CellValuePushed As EventHandler(Of CellValueEventArgs)
Dim instance As GcMultiRow
Dim handler As EventHandler(Of CellValueEventArgs)
 
AddHandler instance.CellValuePushed, handler
[SRCategory("Data")]
[SRDescription("Occurs when the VirtualMode property of the GcMultiRow control is true and a cell value has changed and requires storage in the underlying data source.")]
[Feature(Name="VirtualMode", Version="v5.0")]
public event EventHandler<CellValueEventArgs> CellValuePushed
Event Data

The event handler receives an argument of type CellValueEventArgs containing data related to this event. The following CellValueEventArgs properties provide information specific to this event.

PropertyDescription
CellIndexGets the cell index in its parent Section. (Inherited from GrapeCity.Win.MultiRow.CellEventArgs)
CellNameGets the cell name. (Inherited from GrapeCity.Win.MultiRow.CellEventArgs)
RowIndexGets the index of the owner Row that the event occurs for. (Inherited from GrapeCity.Win.MultiRow.CellEventArgs)
ScopeGets the area of the cell that the event occurs for. (Inherited from GrapeCity.Win.MultiRow.CellEventArgs)
SectionIndexGets the index of the owner Section that the event occurs for. (Inherited from GrapeCity.Win.MultiRow.CellEventArgs)
ValueGets or sets the value that is used as the cell's value.  
Remarks
When a user edits the value of a cell and commits the edited value, the control fires this event to notify you that the value of a specific cell has been changed. You should handle this event to update your data store. The new value information is contained in the CellValueEventArgs.Value property. To locate the cell which has been edited, get the value of the CellEventArgs.SectionIndex (or CellEventArgs.RowIndex), the CellEventArgs.CellIndex (or CellEventArgs.CellName), and the CellEventArgs.Scope in the CellValueEventArgs.
Example
The following code example shows how to edit data and how to save to the data source when MultiRow is in virtual mode. This code example is part of a larger example provided for the VirtualMode property.
void gcMultiRow1_CellValuePushed(object sender, CellValueEventArgs e)
        {
            // When the user edits the value, MultiRow updates the data.
            Student student = userData[e.RowIndex];

            if (e.CellName == "Name")
            {
                student.Name = e.Value.ToString();
            }
            else
            {
                int value;

                if (!int.TryParse(e.Value.ToString(), out value))
                {
                    MessageBox.Show("Score should be a number");
                    return;
                }

                if (e.CellName == "Mathematics")
                {
                    student.MathematicsScore = value;
                }
                else if (e.CellName == "Philosophy")
                {
                    student.PhilosophyScore = value;
                }
            }
        }
Private Sub gcMultiRow1_CellValuePushed(ByVal sender As Object, ByVal e As CellValueEventArgs) Handles 
gcMultiRow1.CellValuePushed
        ' When the user edits the value, MultiRow updates the data.
        Dim student As Student = userData(e.RowIndex)

        If e.CellName = "Name" Then
            student.Name = e.Value.ToString()
        Else
            Dim value As Integer

            If Not Integer.TryParse(e.Value.ToString(), value) Then
                MessageBox.Show("Score should be a number")
                Return
            End If

            If e.CellName = "Mathematics" Then
                student.MathematicsScore = value
            ElseIf e.CellName = "Philosophy" Then
                student.PhilosophyScore = value
            End If
        End If
    End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

GcMultiRow Class
GcMultiRow Members
VirtualMode Property
CellValueNeeded Event
RowDirtyStateNeeded Event
NewRowNeeded Event
CancelRowEdit Event

 

 


Copyright © GrapeCity, inc. All rights reserved.