GrapeCity MultiRow Windows Forms Documentation
NewCellPositionNeeded Event
Example 


Occurs when the current cell is moving to a new position.
Syntax
<SRCategoryAttribute("Behavior")>
<SRDescriptionAttribute("Occurs when CurrentCell is moving to a new position.")>
Public Event NewCellPositionNeeded As EventHandler(Of NewCellPositionNeededEventArgs)
Dim instance As GcMultiRow
Dim handler As EventHandler(Of NewCellPositionNeededEventArgs)
 
AddHandler instance.NewCellPositionNeeded, handler
[SRCategory("Behavior")]
[SRDescription("Occurs when CurrentCell is moving to a new position.")]
public event EventHandler<NewCellPositionNeededEventArgs> NewCellPositionNeeded
Event Data

The event handler receives an argument of type NewCellPositionNeededEventArgs containing data related to this event. The following NewCellPositionNeededEventArgs 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)
MoveStatusGets the status that indicates which behavoir caused the NewCellPositionNeeded event to occur.  
NewCellPositionGets or sets a new current cell position.  
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)
Remarks

The NewCellPositionNeeded event is used to allow the developer to redirect the new cell position when leaving and entering another cell.

The NewCellPositionNeeded event is fired when GcMultRow changes its current cell position from a valid cell position to a new valid cell position. The event order is NewCellPositionNeeded -> CellLeave -> RowLeave -> CellValidating...

The NewCellPositionNeeded event is only fired by keyboard or mouse actions. If you change the CurrentCellPosition or CurrentCell property value with code, the NewCellPositionNeeded event does not fire.

Example
The following code example shows how to use this event to redirect the cell position. To run this example, create a form and add a GcMultiRow control to the form. Add the NewCellPositionNeeded event handler and copy the code to the event handler. Your template should contain two cells named "State" and "Description".
void gcMultiRow1_NewCellPositionNeeded(object sender, NewCellPositionNeededEventArgs e)
        {
            
            if (e.SectionIndex != e.NewCellPosition.SectionIndex)
            {
                object projectState = gcMultiRow1[e.SectionIndex,"State"].Value;
                object description = gcMultiRow1[e.SectionIndex, "Description"].Value;
                if (description == null || object.Equals(string.Empty, description))
                {
                    if(object.Equals(projectState, "Delay"))
                    {
                        MessageBox.Show("If project state is delayed, fill out a description.");

                        e.NewCellPosition = new CellPosition(e.SectionIndex, "Description");
                    }
                }

            }
        }
Private Sub gcMultiRow1_NewCellPositionNeeded(ByVal sender As Object, ByVal e As NewCellPositionNeededEventArgs) Handles gcMultiRow1.NewCellPositionNeeded
       
        If e.SectionIndex <> e.NewCellPosition.SectionIndex Then
            Dim projectState As Object = gcMultiRow1(e.SectionIndex, "State").Value
            Dim description As Object = gcMultiRow1(e.SectionIndex, "Description").Value
            If description = Nothing OrElse Object.Equals(String.Empty, description) Then
                If Object.Equals(projectState, "Delay") Then
                    MessageBox.Show("If project state is delayed, fill out a description.")

                    e.NewCellPosition = New CellPosition(e.SectionIndex, "Description")
                End If

            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

 

 


Copyright © GrapeCity, inc. All rights reserved.