I just downloaded iGrid 4.7 and evaluating it. I just have a quick question regarding formatting cells.
Is there a property somewhere where i can set the horizontal and vertical alignment of the igrid cell's contents before loading the data? Or should i load all the data first and then manually setting every cells horizontal and vertical alignment?

what i wanted to do was to set the horiz/vertical to center before loading all my data from recordset but i cant seem to do it.
are there format properties applicable for all the cells in the grid? or really it should be one by one?

thanks and keep up the good work... igrid is really fast 🙂
A good question - 'cuz it's a typical scenario. Let's see what iGrid can offer.

If you upload data into the grid from a recordset with the help of the FillFromRS method, then we have two subtasks. First you need to create the required set of columns and second set the default properties for their cells before FillFromRS is issued.

The first task can be implemented using the AddCol method or even FillFromRS. If you need to display several columns from the recordset, create the columns using AddCol. If you need all or almost all columns in the grid, use a FillFromRS call like that:

iGrid1.FillFromRS rsMyData, igFillRSRecreateColsOnly

and then hide the unneeded columns (if required) using the ColVisible property.

The second task – setting the cell default properties. After we defined the required columns in the grid, we use so called column default cells to set future cell properties. For your case, say when you need the cells in the ID column centered both horizontally and vertically, the corresponding call can be the following:

iGrid1.ColDefaultCell("ID").eAlignH = igAlignHCenter
iGrid1.ColDefaultCell("ID").eAlignV = igAlignVCenter

Or so:

With iGrid1.ColDefaultCell("ID")
   .eAlignH = igAlignHCenter
   .eAlignV = igAlignVCenter
End With

Do that for all columns you wish to change the default settings for. That's all – now you can call FillFromRS.


One note which can simplify your code. If you create the column set with AddCol's, this method returns a reference to the corresponding column default cell, and you can use it immediately to set the required cell properties. In the case of our sample ID column it would be

With iGrid1.AddCol(sKey:="ID", lWidth:=80)
   .eAlignH = igAlignHCenter
   .eAlignV = igAlignVCenter
End With