GrapeCity MultiRow Windows Forms Documentation
CellValueNeeded Event
Example 


Occurs when the VirtualMode property of a GcMultiRow control is true and the GcMultiRow control requires a cell value in order to format and display the cell.
Syntax
<FeatureAttribute(Name="VirtualMode", Version="v5.0")>
<SRDescriptionAttribute("Occurs when the VirtualMode property of the GcMultiRow control is true and GcMultiRow requires a value for a cell in order to format and display the cell.")>
<SRCategoryAttribute("Data")>
Public Event CellValueNeeded As EventHandler(Of CellValueEventArgs)
Dim instance As GcMultiRow
Dim handler As EventHandler(Of CellValueEventArgs)
 
AddHandler instance.CellValueNeeded, handler
[Feature(Name="VirtualMode", Version="v5.0")]
[SRDescription("Occurs when the VirtualMode property of the GcMultiRow control is true and GcMultiRow requires a value for a cell in order to format and display the cell.")]
[SRCategory("Data")]
public event EventHandler<CellValueEventArgs> CellValueNeeded
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

If you want to display large quantities of tabular data in a GcMultiRow control, you can set the VirtualMode property to true and explicitly manage the control's interaction with its data store. This lets you fine tune the performance.

The control fires this event every time the control needs to paint a cell or get the value of a cell that requires a value from your data store. Handle this event and set the CellValueEventArgs.Value property to a specific value that maps to your data store based on the CellEventArgs.SectionIndex (or CellEventArgs.RowIndex), the CellEventArgs.CellIndex (or CellEventArgs.CellName), and the CellEventArgs.Scope.

If your data is read-only, the CellValueNeeded event may be the only event you need to handle. Additional virtual mode events let you enable specific functionality such as user edits, row addition and deletion, and row-level transactions.

Example
The following code example shows how to load data in cells when the MultiRow control is in virtual mode. This code example is part of a larger example provided for the VirtualMode property.
void gcMultiRow1_CellValueNeeded(object sender, CellValueEventArgs e)
        {
            Student student = null;
            if (e.RowIndex == userData.Count)
            {
                student = uncommitNewStudent;
            }
            else
            {
                student = userData[e.RowIndex];
            }

            // When MultiRow paints a cell, the control gets the value of the specific cell with this event.
            if (e.CellName == "Name")
            {
                e.Value = student.Name;
            }
            if (e.CellName == "Mathematics")
            {
                e.Value = student.MathematicsScore;
            }
            if (e.CellName == "Philosophy")
            {
                e.Value = student.PhilosophyScore;
            }
            if (e.CellName == "ID")
            {
                e.Value = student.ID;
            }
        }
Private Sub gcMultiRow1_CellValueNeeded(ByVal sender As Object, ByVal e As CellValueEventArgs) Handles 
gcMultiRow1.CellValueNeeded
        Dim student As Student = Nothing
        If e.RowIndex = userData.Count Then
            student = uncommitNewStudent
        Else
            student = userData(e.RowIndex)
        End If

        ' When MultiRow paints a cell, the control gets the value of the specific cell with this event.
        If e.CellName = "Name" Then
            e.Value = student.Name
        End If
        If e.CellName = "Mathematics" Then
            e.Value = student.MathematicsScore
        End If
        If e.CellName = "Philosophy" Then
            e.Value = student.PhilosophyScore
        End If
        If e.CellName = "ID" Then
            e.Value = student.ID
        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
CellValuePushed Event
RowDirtyStateNeeded Event
NewRowNeeded Event
CancelRowEdit Event

 

 


Copyright © GrapeCity, inc. All rights reserved.