Philippe
2012-10-20T17:23:01Z
Hi,

I'm a newcomer to iGrid. I browsed the forum, but I did not see anythink about my issue.

I would like to take advantage of the FillFromRS method in iGrid, but in an seemingly undocumented way.

Reading the .chm file, I understand that, to make short, the recordset fields are linked to iGrid's columns and populate them directly when using that method.

What I would like to do is displaying each record data on two lines per row, rather than just in one line of cells. Somewhat like in the Outlook example.

Like in that example, I'd like to show, say, 3 fields/cells in the first line of each row, and a 4th field from the same recordset in a "rowcell", under those 3 cells.

Is it be possible to achieve that through the use of the FillFromRS method, or should I go through the recordset and, with a loop, add and populate iGrid's rows one by one, by adding rows and inner cells programmatically for each record?

(I hope I was clear)
Thanks in advance

Philippe
(Access 2010 VBA)
Philippe
2012-10-21T14:22:38Z
Hi again,

In fact, you can forget my question. I decided to populate iGrid with a loop going through my recordset. The process is quite fast... if I don't forget to use the BeginUpdate/EndUpdate pair.

Moreover, this way gives me more control on the data layout than FillFromRS. I noticed that the vbCrLf constant works in the rowtextcol, which allows me to break-down the data in two lines in the rowtextcol in order to get the visual result I wanted :

The seeked result

For the iGrid newbies like me who could be interested, here is the code :

Private Sub Form_Load()
Dim oGrid As iGrid
Set oGrid = iGrid0.Object
Dim dbs As dao.Database
Dim rst As dao.Recordset

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("q_Project_List")

rst.MoveLast   ' this is to get the rst recordcount
rst.MoveFirst

    With oGrid
        .BeginUpdate    'Temporary deactivates screen refreshing         
 
       'General Grid Formatting 
        .Header.Visible = False
        .DrawRowText = True
        .DefaultRowHeight = 50
        .BackColor = RGB(242, 242, 242)
        .BackColorEvenRows = RGB(236, 236, 236)
        .HighlightBackColor = COUL_ENR_ACTIF
        .HighlightForeColor = RGB(0, 0, 0)
        .FocusRect = False
        .HScrollBar.DisplayMode = igScrollBarDisplayNever
        
        'Create columns
        .AddCol sKey:="Id_Project", sHeader:="Id", lwidth:=0, bvisible:=False
        .AddCol sKey:="ClientName", sHeader:="Client", lwidth:=270
        .AddCol sKey:="Paid", sHeader:="Paid", lwidth:=0, bvisible:=False
        
        'Create rows        
        For i = 1 To rst.RecordCount
            .AddRow
           ' RowLine1, Col 1 (unvisible)
                .CellValue(i, 1) = rst.Fields("Id_Project")
           ' RowLine1, Col 2 (the sole visible column)
                .CellValue(i, 2) = rst.Fields("ClientName")
                .CellIndentLeft(i, 2) = 3
                With .CellFont(i, 2)
                    .Name = "Calibri"
                    .Size = 9
                    .Bold = True
                End With
           ' RowLine1, Col 3 (unvisible, boolean – will be used for filtering purposes, (e.g., the RowVisible property will be set to False for Paid records))
                .CellValue(i, 3) = rst.Fields("Paid")

           ' RowLine 2
                .CellValue(i, .RowTextCol) = rst.Fields("File") & " - " & rst.Fields("Contact") & vbCrLf & rst.Fields("Proj_Det")
                .CellIndentLeft(i, .RowTextCol) = 10
                .CellForeColor(i, .RowTextCol) = RGB(64, 64, 144)
                With .CellFont(i, .RowTextCol)
                    .Name = "Calibri"
                    .Size = 8
                    .Bold = False
                End With
            
            If Not rst.EOF Then rst.MoveNext
        Next
        
        'Set focus on first row
        .SetCurCell 1, 1
        
        .EndUpdate     'don't forget to reactivate screen refreshing
    End With
    
Set rst = Nothing
Set dbs = Nothing
Set oGrid = Nothing
End Sub