GrapeCity MultiRow Windows Forms Documentation
CurrentCellPosition Property
Example 


Gets or sets a value that indicates the currently active cell position.
Syntax
<BrowsableAttribute(False)>
<DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)>
<FeatureAttribute(Name="CurrentCell", Version="v5.0")>
Public Property CurrentCellPosition As CellPosition
Dim instance As GcMultiRow
Dim value As CellPosition
 
instance.CurrentCellPosition = value
 
value = instance.CurrentCellPosition
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Feature(Name="CurrentCell", Version="v5.0")]
public CellPosition CurrentCellPosition {get; set;}

Property Value

A CellPosition that indicates the currently active cell position.
Exceptions
ExceptionDescription
System.ArgumentException

The specified CellPosition is unselectable, invisible, or in a row which is invisible.

-or-

The row index or cell index in the specified CellPosition is out of range or the cell name is invalid.

System.InvalidOperationException

The ViewMode is ViewMode.Display.

-or-

The ViewMode is ViewMode.ListBox.

-or-

The GcMultiRow control has no Template.

-or-

The current cell cannot be committed or canceled.

Remarks
Setting this property can also change the current cell, and the current cell is not instantiated.
Example
The following code example shows how to set the CurrentCellPosition property when the CellMouseDown event occurs. This code example is part of a larger example provided for the Section.ContextMenuStrip property.
void gcMultiRow1_CellMouseDown(object sender, CellMouseEventArgs e)
       {
           if (e.Button == MouseButtons.Right)
           {
               if (e.Scope == CellScope.Row && gcMultiRow1.Template.Row.Cells[e.CellIndex].Selectable)
               {
                   gcMultiRow1.CurrentCellPosition = new CellPosition(e.Scope, e.SectionIndex, e.CellIndex);
               }
               if (gcMultiRow1.GetValue(e.SectionIndex, e.CellIndex) != null)
               {
                   cut.Enabled = true;
                   copy.Enabled = true;
               }
               else
               {
                   cut.Enabled = false;
                   copy.Enabled = false;
               }

               if (e.Scope == CellScope.Row && e.SectionIndex != gcMultiRow1.RowCount - 1)
               {
                   sectionMenuStrip.Enabled = true;
                   sectionMenuStrip.Tag = new CellPosition(e.Scope, e.SectionIndex, e.CellIndex);
               }
               else
               {
                   sectionMenuStrip.Enabled = false;
               }

               if (Clipboard.ContainsText())
               {
                   paste.Enabled = true;
               }
               else
               {
                   paste.Enabled = false;
               }
           }
       }
Private Sub gcMultiRow1_CellMouseDown(ByVal sender As Object, ByVal e As CellMouseEventArgs) Handles gcMultiRow1.CellMouseDown
        If e.Button = MouseButtons.Right Then
            If e.Scope = CellScope.Row AndAlso gcMultiRow1.Template.Row.Cells(e.CellIndex).Selectable Then
                gcMultiRow1.CurrentCellPosition = New CellPosition(e.Scope, e.SectionIndex, e.CellIndex)
            End If
            If gcMultiRow1.GetValue(e.SectionIndex, e.CellIndex) <> Nothing Then
                cut.Enabled = True
                copy.Enabled = True
            Else
                cut.Enabled = False
                copy.Enabled = False
            End If

            If e.Scope = CellScope.Row AndAlso e.SectionIndex <> gcMultiRow1.RowCount - 1 Then
                sectionMenuStrip.Enabled = True
                sectionMenuStrip.Tag = New CellPosition(e.Scope, e.SectionIndex, e.CellIndex)
            Else
                sectionMenuStrip.Enabled = False
            End If

            If Clipboard.ContainsText() Then
                paste.Enabled = True
            Else
                paste.Enabled = False
            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
CurrentCell Property

 

 


Copyright © GrapeCity, inc. All rights reserved.