exGrid is an ActiveX grid control by Exontrol Software, Inc.
exGrid can be used with VFP 3.0 and above. The information below was mostly gathered during development in VFP 9.0, and may need to be "tweaked for earlier versions of VFP. It has some very unique features and acts almost as much like a Tree View control as a Grid control. One cool feature is the built in ability to handle multiple embedded ActiveX controls. This means you can create grid hierarchies, insert calendars, web pages, Word/Excel docs, maps, images, etc. and they appear as part of your grid. Another cool thing is their documented support for VFP!
exGrid is part of the extensive "exSuite" of controls by Exontrol.
Main Site: http://www.exontrol.com
exGrid FAQ: http://www.exontrol.com/faq.jsp?product=exgrid
exGrid Release Notes: http://www.exontrol.com/notes.jsp?product=exgrid
General FAQ: http://www.exontrol.com/sg.jsp?content=support/faq
Custom VFP exGrid Class (exVGrid): ftp://220.127.116.11/VFP/
I (Paul James) have created a custom VFP 9.0 class that wraps much of the exGrid control functionality. Download the exVGrid.zip from the FTP site listed above.
The zip file contains:
- VFP project
- Sample VFP Screen
- exVGrid Class code (including event handler, event logging, printing)
- exGrid #DEFINE (constants)
- VFP exGrid "events" Interface Class
The classes/screen will work with earlier version of VFP with some modifications. Prior to VFP 9.0, VFP was not able to handle the "hItem" data type (Long Unsigned Integer I think). VFP fires an "Invalid Subscript Range" error when it tries to process a number greater than 65000. Since, the HITEM is a long value that most of the time exceeds 65000, Exontrol added a property in the control that could accept the "hItem" for VFP, it is called "DefaultItem". Prior to v9, you have to use this property instead of using a VFP variable.
So, when working with exGrid in version of VFP prior to 9.0, you must do something like the following:
.Items.DefaultItem = .Items.AddItem("Item 1")
.Items.CellImage(0,1) = 2
In VFP 9.0 (and later), you can do this:
x = .Items.AddItem("Item 1")
.Items.CellImage(x,1) = 2
Printing/Previewing a grid "exactly" as it appears on the screen is as easy as dropping the included exPrint control on your form, then putting this code behind a commandbutton:
thisform.exPrint1.PrintExt = thisform.exGrid1.Object
*Notice I used the "Object" property to get around the OLE object that VFP creates.
*Note: The Print control will not recurse into contained ActiveX controls (child grids) and print them.
See the Wiki topic Ole Objects for more info on this.
*An "Item" is a "Row" in database terminology.
- Add Item
Use to add new items that have no parent. This applies to "root" items in a "tree" or any item in a "list".
Grid1.Items.DefaultItem = Grid.Items.AddItem("New Row")
Use to insert child items "underneath" existing parent items (used when displaying items in "Tree"/Hierarchy).
Grid1.Items.DefaultItem = Grid1.Items.InsertItem(liParentItem,,"New Child")
Use to insert items that contain ActiveX controls like an "additional child grid", browser, document, calendar, etc.
i = Grid1.Items.InsertControlItem(0,"Exontrol.Grid")
Grid1.Items.DefaultItem = i
Grid1.Items.ItemHeight(0) = 128
Grid1.Items.DefaultItem = .Items.InsertControlItem(,"http://www.exontrol.com")
Grid1.Items.ItemAppearance(0) = 1
Grid1.Items.ItemHeight(0) = 196
Grid1.Items.InsertControlItem(0,"MSHTML:This is a line of text") &&HTML or XML
hCalc = Grid1.Items.InsertControlItem(, "MSCal.Calendar")
Now get an object reference to the newly inserted control to change some of the control's properties.
oCalc = Grid1.Items.ItemObject(hCalc)
oCalc.ShowTitle = False
oCalc.ShowDateSelectors = False
Takes an array and creates 1 Item/Row in the Grid for each 1 Row of the array.
The "contents" of the array member becomes the "value" for the first column in each new item/row.
If you want to load 2 columns of "values", use a two-dimensional array, and so on.
Note - this is a "grid" method, not a "grid.items" method.
The DataSource property binds the "grid" to an ADO recordset.
Setting DataSource property does the following:
1. Clears the columns collection,
2. Adds a Column for each "field" in the recordset.
3. Adds an Item/row for each "record" in the recordset (fires the "Add Item" method).
Each column's "EditType" is set according to the data type of each field.
Accessing Items, Columns, and Cells
First Cell of the First Item
Each of the following lines of code are equivalent:
So, any of the above could be used in the following:
Thisform.Grid1.Items._AnyCellProperty_(_AnyOfTheAbove_) = .T.
Thisform.Grid1.Items.CellHasButton(Thisform.Grid1.Items(0), 0) = .T.
Changing Item properties or contents
Notice, the Grid does not have an "Item" property to refer to a single item (ie Grid1.Items.Item).
Instead, you to establish a "default" item as any single item from the Grid.Items collection (ie Grid1.Items.DefaultItem).
Once the "default" item is set, you do not need to reference it explicitly.
Grid1.Items.DefaultItem = Grid1.Items(0) &&Existing Item
Grid1.Items.DefaultItem = Grid1.Items.AddItem("Test") &&Add a new item and make it the "default".
Grid1.Items.DefaultItem = Grid1.Items.InsertItem(i,,"Child") &&Add a new child item and make it the "default".
lnItem = Grid1.Items.AddItem("Test") &&Add a new item, assign it to a variable.
Grid1.Items.DefaultItem = lnItem &&Set the default item to the variable.
When a new item is added, the Add Item() or InsertItem() methods return a "handle" (unsigned Long Integer).
This "handle" is basically, an offset into the array of Grid.Items.
The "handle" can be used to specify an Item in the Items collection.
h = Grid1.Items.AddItem("Test") &&Set the Handle
Grid1.Items.CellValue(h, 1) = "Simple Text" &&Use the Handle
Note that every "method" in the Grid.Items collection has the same 1st parameter: Item
Item = A (long Integer) "handle" pointing to a specific Item in the Grid.Items collection.
If you leave out the "Item" parameter, or use zero (0), you will get the "DefaultItem".
*Note that all of the "Cell methods" in the Grid.Items collection have the same 2nd Parameter: ColIndex
ColIndex = An integer representing the "column" or "cell" you want to access.
If you leave out the this parameter, or use zero (0), you will get the first column.
Assigning Values/Data to Cells:
Add Item() or InsertItem() methods, usually specify the value for the 1st "cell" in a "row/item".
Grid1.Items.DefaultItem = Grid1.Items.AddItem("Item 1 NEW! HTML Formatting Suport")
Specifies the "value" for cells in additional columns.
Grid1.Items.CellValue(0,0) = "Value"
Associates "user data" with a cell.
Value that indicates the index of the "icon" (16x16 size) in the grid's "Images Collection".
Grid1.Items.CellImage(0,0) = 1
Used to display larger sized images in a cell
Gird1.Items.CellPicture(0,0) = Load Picture("mypic.gif")
Additional Cell Properties:
Affects only checkbox/radio cells. 1=Checked, 0=UnChecked, 2=Partially Checked
Grid1.Items.CellState(0,0) = 1
Place a Checkbox or Radiobutton in a cell.
Grid1.Items.CellHasCheckBox(0,0) = .t.
Grid1.Items.CellHasRadioButton(0,0) = .t.
Specifies the images to use if a cell is a checkbox or radiobutton.
Grid1.Items.CheckImage(0) = 5
Indicates whether the cell uses one line or multiple lines (if needed).
Grid1.Items.CellSingleLine(0,0) = .f.
CellBold(0,0) = .t.
CellItalic(0,0) = .t.
CellEditor(0,0) - Editor specific to one cell, overrides the Column.Editor
.Columns(0).HeaderImage = 1
.Columns(0).HeaderImageAlignment = 2
.Columns(0).Editor.EditType - Specifies the "Editor Type" for this Column
0 = None (text only)
1 = EditType (multi-function text editor)
2 = DropDownType
3 = DropDownListType
4 = SpinType
5 = MemoType (dropdown extended text editor)
6 = CheckListType
7 = DateType (calendar dropdown)
8 = MaskType (masked input)
9 = ColorType (extended color picker)
10 = FontType (font picker)
11 = PictureType (display picture)
12 = ButtonType
13 = Progress Bar Type
14 = PickEditType (pick list user can edit)
15 = LinkEditType (editable web address)
16 = UserEditorType (any ActiveX control)
17 = ColorListType (simple color picker)
18 = MemoDropDownType (scrollable text editor)
19 = CheckValueType (displays checkbox)
20 = SliderType (puts a slider in the cell)
.Items.ItemForeColor(0) = 0
.Items.ItemBackColor(0) = 255
.Items.ItemHeight(0) = 44
.Items.ExpandItem(0) = .t.
Child grid Column/Item access:
.Items.ItemObject(0).Columns.Add("Column added at runtime")
.Items.ItemObject(0).Items.AddItem("Item added at runtime")
Download the exVGrid Class and Sample form from: ftp://18.104.22.168/VFP/
The following is an example of a very simple one-column grid with manually inserted rows:
Application.AutoYield = .f. &&Allow exGrid to capture events.
Local oFont as Object, oGrid as Object, oChild as Object, iChild as Long, iItem as Long
Store .NULL. to oFont, oGrid, oChild
Store 0 to iChild, iItem
oFont = CreateObject("StdFont") &&Font Object, used to set grid font properties.
oGrid = thisform.exGrid1
*Setup Main Grid appearance.
oFont.Name = "Tahoma"
oFont.Bold = .F.
oFont.Size = 8
.Font = oFont
.SortOnClick = exNoSort &&Disable user sorting on header click.
.LinesAtRoot = .f.
.DefaultItemHeight = 16
.ScrollBySingleLine = .t.
.MarkTooltipCells = .f.
.SelForeColor = RGB(0,0,0)
.SelBackColor = RGB(240,240,240)
.BackColor = RGB(255,255,255)
.ForeColor = RGB(0,0,0)
*Add a column
.Columns(0).Alignment = exLeftAlignment &&Align Cells in Column. 0=Left, 1=Center, 2=Right
.Columns(0).HeaderAlignment = exCenterAlignment &&Aligns the caption inside the column header. 0=Left, 1=Center, 2=Right
.Columns(0).HeaderBold = .F.
.Columns(0).HTMLCaption = "Invoice # 12345"
.Columns(0).Editor.EditType = exReadOnly &&No Editor
*Insert records into grid.
Do While !Eof()
iItem = oGrid.Items.AddItem(Alltrim(myTable.myField))
Both eXGrid and eXList don't work in Virtual Mode under VFP9.0 SP1. VFP8 works great.
Category Third Party Tools
Category Third Party Products