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
Edited by user
2014-06-27T08:21:57Z
|
Reason: Igor/10Tec added code formatting