ActiveReports 19 .NET Edition
MESCIUS.ActiveReports.Design.Win Assembly / GrapeCity.ActiveReports.Design Namespace / Selection Class / Item Property
Specifies the index of the selected item.
Example

In This Topic
    Item Property (Selection)
    In This Topic
    Returns a reference to the specified selected item.
    Syntax
    'Declaration
     
    Public ReadOnly Default Property Item( _
       ByVal index As Integer _
    ) As Object
    public object this[ 
       int index
    ]; {get;}

    Parameters

    index
    Specifies the index of the selected item.

    Property Value

    The component at the specified index. If the index is out of range, this will throw an System.IndexOutOfRangeException.
    Exceptions
    ExceptionDescription
    Thrown when the index is outside the bounds of the collection.
    Remarks
    This indexer provides direct access to a specific component within the selection. It is useful for iterating over the selected components or accessing a component at a specific position.
    Example
    /// <summary>
    /// SetClassName - sets the ClassName of the selected object to the name in the drop down list
    /// </summary>
    private void SetClassName()
    {
        for(int i=0;i<this.ardMain.Selection.Count;i++)
        {
            string ctl = this.ardMain.Selection[i].GetType().ToString();
            if((ctl.IndexOf("TextBox") >0)||(ctl.IndexOf("CheckBox") >0)||(ctl.IndexOf("Label") >0))
            {
                switch(ctl)
                {
                    case "GrapeCity.ActiveReports.SectionReportModel.TextBox":  //Control type is TextBox
                        ((GrapeCity.ActiveReports.SectionReportModel.TextBox)this.ardMain.Selection[i]).ClassName = this.cboClassName.Text;
                        break;
                    case "DGrapeCity.ActiveReports.SectionReportModel.Label":  //Control type is Label
                        ((GrapeCity.ActiveReports.SectionReportModel.Label)this.ardMain.Selection[i]).ClassName = this.cboClassName.Text;
                        break;
                    case "GrapeCity.ActiveReports.SectionReportModel.CheckBox":  //Control type is CheckBox
                        ((GrapeCity.ActiveReports.SectionReportModel.CheckBox)this.ardMain.Selection[i]).ClassName = this.cboClassName.Text;
                        break;
                }
            }    
        }    
    }
    'SetClassName - sets the ClassName of the selected object to the name in the drop down list
    Private Sub SetClassName()
        Dim i As Integer
        For i = 0 To (Me.ardMain.Selection.Count) - 1
            Dim ctl As String = Me.ardMain.Selection(i).GetType().ToString()
            If ctl.IndexOf("TextBox") > 0 OrElse ctl.IndexOf("CheckBox") > 0 OrElse ctl.IndexOf("Label") > 0 Then
                Select Case ctl
                    Case "GrapeCity.ActiveReports.SectionReportModel.TextBox" 'Control type is TextBox
                        CType(Me.ardMain.Selection(i), GrapeCity.ActiveReports.SectionReportModel.TextBox).ClassName = Me.cboClassName.Text
                    Case "GrapeCity.ActiveReports.SectionReportModel.Label" 'Control type is Label
                        CType(Me.ardMain.Selection(i), GrapeCity.ActiveReports.SectionReportModel.Label).ClassName = Me.cboClassName.Text
                    Case "GrapeCity.ActiveReports.SectionReportModel.CheckBox" 'Control type is CheckBox
                        CType(Me.ardMain.Selection(i), GrapeCity.ActiveReports.SectionReportModel.CheckBox).ClassName = Me.cboClassName.Text
                End Select
            End If
        Next i
    End Sub 'SetClassName
    See Also