Share via


SortFields.Item Property

Gets the object at the specified index. In C#, this property is the indexer for the SortField class.

Namespace CrystalDecisions.CrystalReports.Engine Assembly CrystalDecisions.CrystalReports.Engine (CrystalDecisions.CrystalReports.Engine.dll)

Syntax

'Declaration

Public Overrideable ReadOnly Property Item ( _
    ByVal index As Integer _    
) As CrystalDecisions.CrystalReports.Engine.SortField
public virtual CrystalDecisions.CrystalReports.Engine.SortField this [
    int index
]{get;}

Parameters

  • index

Property Value

The value in the collection at the specified index.

Remarks

This property allows you to access a specific item in the collection. The item is referenced using a numeric, zero-based index.

The property name Item does not exist for C#. To access an item in a collection using C#, use the syntax: collection[0].

Example

This example updates the sorted database field.

'Declaration

      Private Sub UpdateSortField(ByVal myReportDocument As ReportDocument, ByVal tableName As String, ByVal fieldName As String)
         Dim myDatabaseFieldDefinition As DatabaseFieldDefinition

         myDatabaseFieldDefinition = myReportDocument.Database.Tables.Item(tableName).Fields.Item(fieldName)

         Dim mySortField As SortField = myReportDocument.DataDefinition.SortFields.Item(1)

         If (mySortField.SortType = SortFieldType.RecordSortField) Then
           mySortField.Field = myDatabaseFieldDefinition
           mySortField.SortDirection = SortDirection.AscendingOrder
         End If
      End Sub
      
      private void UpdateSortField(ReportDocument reportDocument, String tableName, String fieldName)
      {
         DatabaseFieldDefinition databaseFieldDefinition;

         databaseFieldDefinition = reportDocument.Database.Tables[tableName].Fields[fieldName];

         SortField sortField = reportDocument.DataDefinition.SortFields[1];

         if (sortField.SortType == SortFieldType.RecordSortField)
         {
           sortField.Field = databaseFieldDefinition;
           sortField.SortDirection = SortDirection.AscendingOrder;
         }
      }
      

Version Information

Crystal Reports Basic for Visual Studio 2008

Supported since: Crystal Reports for Visual Studio .NET 2002

See Also

Reference

SortFields Class
SortFields Members
CrystalDecisions.CrystalReports.Engine Namespace