Item Property
Description
Returns a GridRecordItem by its index from the collection of GridRecordItem.
Property Type
Read-only property
Syntax (Visual Basic)
Public Property Item( _
ByVal Index As Long _
) As [GridRecordItem](XtremeGridControl~GridRecordItem.md)
Parameters
- Index: Index of a GridRecordItem within the collection.
Remarks
The GridRecord can be thought of as a row (the GridRecord is actually attached to a GridRow and the row displays the GridRecordItem stored in the GridRecord), and the GridRecordItem can be thought of as the individual cells in the row.
Each GridRecordItem has to be added to a GridRecord before it can be used in the GridControl. The GridRecord contains a collection of GridRecordItems, and the records are referenced by the value in the index. The first GridRecordItem added to the collection has an index of zero, and the index is incremented by 1 for each GridRecordItem added. The index of the GridRecordItems in the collection corresponds with the ItemIndex of a GridColumn. The GridRecordItem will be displayed in the column that has an ItemIndex that is the same as the index in the GridRecordItem collection.
You can use the Insert and RemoveAt methods to insert and remove GridRecordItems from the collection.
Example
GridRecord Item Sample (Visual Basic)
This sample illustrates one way to use the GridRecord Item property. This sample mimics the Read function of most email programs, where you place a checkmark in the rows you want to mark as Read and then click the Mark as Read button.
' For this sample, assume that records are added in the format below,
' The first GridRecordItem contains an image, the second contains a checkbox
Dim Record As GridRecord
Dim Item As GridRecordItem
' Adds a record
Set Record = wndGridControl.Records.Add
' Adds a GridRecordItem that displays an Icon
Set Item = Record.AddItem("")
' Assign a "Un-Read" icon
Item.Icon = 2
' Adds a GridRecordItem that displays a checkbox
Set Item = Record.AddItem("")
Item.HasCheckbox = True
Item.Checked = False
Record.AddItem "RE: Your Invoice"
Record.AddItem "John Smith"
Record.AddItem "19/06/2004"
Record.AddItem "18k"
wndGridControl.Populate
' When this command button is clicked, all rows/records that have a check mark
' in the checkbox in the second GridRecordItem will be marked as "Read" and the
' icon will be changed, and the checkmark is removed
Private Sub cmdMarkAsRead_Click()
Dim Record As GridRecord
Dim Row As GridRow
For Each Row In wndGridControl.Rows
' This line of code is accessing the 2nd GridRecordItem of the GridRecord/Row
' You can access each individual GridRecordItem by its index (starting at zero)
' through the Item property
If Row.Record.Item(1).Checked Then
' Change the GridRecordItem's Icon to a "Read" icon
Row.Record.Item(0).Icon = 3
' Remove the check mark from the GridRecordItem's checkbox
Row.Record.Item(1).Checked = False
' Mark the GridRecord as "Read"
Row.Record.Tag = "Read"
End If
Next
' Update the GridControl to show changes
wndGridControl.Redraw
End Sub
' This event occurs before the rows are drawn and is used to modify the style of the GridRecordItem's before they are displayed.
Private Sub wndGridControl_BeforeDrawRow(ByVal Row As XtremeGridControl.IGridRow, ByVal Item As XtremeGridControl.IGridRecordItem, ByVal Metrics As XtremeGridControl.IGridRecordItemMetrics)
' If the GridRecord was marked as "Read", then change the BackColor of its GridRecordItem's
' to a shade of gray.
If Row.Record.Tag = "Read" Then
Metrics.BackColor = RGB(224, 224, 224)
End If
' If the GridRecord was marked as "UnRead", then change the BackColor of its GridRecordItem's
' to white.
If Row.Record.Tag = "UnRead" Then
Metrics.BackColor = RGB(255, 255, 255)
End If
End Sub
See Also
Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.