GrapeCity.Win.MultiRow Namespace > GcMultiRow Class : CellValueNeeded Event |
<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
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.
Property | Description |
---|---|
CellIndex | Gets the cell index in its parent Section. (Inherited from GrapeCity.Win.MultiRow.CellEventArgs) |
CellName | Gets the cell name. (Inherited from GrapeCity.Win.MultiRow.CellEventArgs) |
RowIndex | Gets the index of the owner Row that the event occurs for. (Inherited from GrapeCity.Win.MultiRow.CellEventArgs) |
Scope | Gets the area of the cell that the event occurs for. (Inherited from GrapeCity.Win.MultiRow.CellEventArgs) |
SectionIndex | Gets the index of the owner Section that the event occurs for. (Inherited from GrapeCity.Win.MultiRow.CellEventArgs) |
Value | Gets or sets the value that is used as the cell's value. |
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.
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
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