GrapeCity MultiRow Windows Forms Documentation
Selected Property (Cell)
Example 


Gets or sets a value that indicates whether this Cell is selected.
Syntax
<EditorBrowsableAttribute(EditorBrowsableState.Advanced)>
<BrowsableAttribute(False)>
<DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)>
Public Property Selected As Boolean
Dim instance As Cell
Dim value As Boolean
 
instance.Selected = value
 
value = instance.Selected
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool Selected {get; set;}

Property Value

true if selected; otherwise, false. The default is false.
Exceptions
ExceptionDescription
System.InvalidOperationException

Sets the property at design time.

-or-

Sets the property to true when the Cell is not selectable.

-or-

Sets the property to true when the Scope is not CellScope.Row and the GcMultiRow.ViewMode is ViewMode.ListBox.

Example
The following code example shows how to use this property to retrieve the selection information. This code example is part of a larger example provided for the GcMultiRow.ViewMode class.
void getSelectionInformationButton_Click(object sender, EventArgs e)
        {
            string info = null;

            // Get a specific cell's selection state.
            info = "First Cell's Selection State: " + gcMultiRow1[0, 0].Selected;

            info += "\r\n\r\n";

            // Get a specific row's selection state.
            info += "First Row's Selection State: " + gcMultiRow1.Rows[0].Selected;

            info += "\r\n\r\n";

            info += "Selected cells List:";

            // Get all selected cells.
            foreach (Cell cell in this.gcMultiRow1.SelectedCells)
            {
                info += "\r\n";

                info += "RowIndex: " + cell.RowIndex + ", CellIndex: " + cell.CellIndex;
            }

            info += "\r\n\r\n";

            info += ("Selected rows List:");

            // Get all selected rows.
            foreach (Row row in this.gcMultiRow1.SelectedRows)
            {
                info += "\r\n";

                info += "RowIndex: " + row.Index;
            }

            MessageBox.Show(info);
        }
Private Sub getSelectionInformationButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles 
getSelectionInformationButton.Click
        Dim info As String = Nothing

        ' Get a specific cell's selection state.
        info = "First Cell's Selection State: " + gcMultiRow1(0, 0).Selected.ToString()

        info += vbCr & vbLf & vbCr & vbLf

        ' Get a specific row's selection state.
        info += "First Row's Selection State: " + gcMultiRow1.Rows(0).Selected.ToString()

        info += vbCr & vbLf & vbCr & vbLf

        info += "Selected cells List:"

        ' Get all selected cells.
        For Each cell As Cell In Me.gcMultiRow1.SelectedCells
            info += vbCr & vbLf

            info += "RowIndex: " + cell.RowIndex.ToString() + ", CellIndex: " + cell.CellIndex.ToString()
        Next

        info += vbCr & vbLf & vbCr & vbLf

        info += ("Selected rows List:")

        ' Get all selected rows.
        For Each row As Row In Me.gcMultiRow1.SelectedRows
            info += vbCr & vbLf

            info += "RowIndex: " + row.Index.ToString()
        Next

        MessageBox.Show(info)
    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

Cell Class
Cell Members
Selected Property

 

 


Copyright © GrapeCity, inc. All rights reserved.