THyperGrid Revision History
No changes, simply included version for Delphi 5.0 - sorry.
Added OnExitRow and OnEnterRow events. These are self explanatory.
The ThgColorDialog component does not register itself by default any more.
Added a method called ClearHeadings, which should be used instead of Headings.Clear. The latter will cause a List Index Out Of Bounds error. Thanks to Carlos Mercado for finding this one.
Added support for combo boxes that only accept input from the items in the list. This can be set at design time from the "Control" page of the columns property editor. Simply set the check box labeled "Drop down list" and the user will not be able to type into the combo box, he/she will only be able to select one of the items in the list. Unfortunately, this disables the hints for the combo box but, when the list is dropped down, you can still type to find a specific item. To set this at run time, use
HyperGrid1.Columns[ Col ].DropDownList := True;
This is only valid for columns with the control type including hgctlComboBox and the default behavior is that of a regular editable combo box.
THyperGrid now has its first official help file! Check it out.
The columns property editor can now be invoked at run time. I had to do this so that I could test it easily. You can now invoke it with a statement like this:
TfrmhgColumnsEditor.CreateColumnsEditor( Self , HyperGrid1 ).ShowModal;
This can be done if you would like your users to modify the columns at run-time, but I don't suspect many people do. Don't forget to add HgDialog to your uses clause if you do this.
Added a method called LoadFromDataSet. As its name implies, this allows you to load any TDataSet into the grid.
procedure LoadFromDataSet( DataSet : TDataSet; LoadFieldNames : Boolean; StartCol , StartRow : Longint );
The DataSet parameter is the source data set ( TQuery, TTable, etc. ). If LoadFieldNames is True, the field names for each column are loaded into the grid from the data set, otherwise, no field names are loaded. The StartCol and StartRow let you specify where the data set will be loaded. If the data set has more rows than the grid, rows are added accordingly. If the data set has more columns than the grid, columns are added accordingly. If the grid has hidden columns, they will be populated as well. So, for example, you can hide the first column, load a data set that has an id that you don't wish to display as the first field, and it will be loaded into the hidden grid column, so you can always refer to it. The StartCol and StartRow parameters allow you to load the data set in a specific portion of the grid. LoadFromFile also has these parameters, so you can potentially load part of the grid from a data set, and part from a file.
Version 1.70 - Never released
Added support for Delphi 4. This required modification to the DPK file. Now the same DPK can be used for Delphi 3 and Delphi 4 ( with conditional compilation )
There was an "Index out of bounds" error when invoking the columns property editor at design time. This was only manifested in Delphi 4, and has been fixed. It seems that in D4, when a list box has no items, the ItemIndex property can be zero. Not the case in D3.
The Clear method now clears all hidden columns as well as visible columns. Note that the ClearRange method does NOT clear hidden columns.
Added Rows property to the Column object.
To access a hidden column's data, you had to use the following notation :
Columns[ 1 ].Cols[ 2 ]
This was meant to get the item at column 1 and row 2. As you can see, the Cols property is a gross misnomer. So, I have added a property called Rows, which serves the same purpose. Now, you can write:
Columns[ 1 ].Rows[ 2 ]
I have not removed the old Cols property, to ease the transition, but will remove it in a future version.
DeleteRow method now overrides the inherited one.
Updated the DCR file, so bitmap is a little nicer now. Added the following methods : SaveToFile, SaveToStream, LoadFromFile and LoadFromStream. See the HyperFAQ document for more details. Added a protected virtual method called SolveFornula, which is called by GetDisplayText. This allows spreadhseet behavior and maintains compatibility with the existing OnGetDisplayText event. The spreadsheet behavior is not in THyperGrid, but in an upcoming component, THyperSpreadsheet, which is derived from THyperGrid.
Now HgGlobal uses an iclude file to read its version number, this is to simplify versioning with my new makefile.
Adjusted vertical margin so that when text is top-aligned, there is no difference in placement when the text is edited. Added OnComboSelection event. See HyperFAQ document for more details. Added call to hide editor before the grid is cleared, rows are inserted, or rows are deleted. This prevents funky behavior when a combo in a cell is showing and the row is deleted. Added private IsFixedCell method to simplify things. Documentation moved to HTML format ( about time ) The column click rectangle has been adjusted taking into acount the options, goColSizing , goColMoving , goRowSizing and go RowMoving. See the HyperFAQ document for more details.
Changed the ThgColumns and ThgHeadings array properties to public rather than published to make C++ Builder 3 happy.
Made some changes to satisfy Borland C++ Builder.
It did not process the following correctly:
1) Initializing a constant set type to an empty set.
2) A pascal class function - C++ static method was generated incorrectly
Fixed two problems with Exit cell and enter cell
1) By Keith Darragh
When the exit cell event handler specified CanExit False, It would not work correctly the second time. 2) The very first enter cell and subsequent ExitCell where not being executed correctly due to a problem with initialization.
Ok, there was a serious problem with Win95. The same code that works just fine on NT 4.0 does not work with windows 95 and causes a nasty
system crash. The code has been removed until I can investigate further.
The only symptom of removing the code is that cell hints will not go away when
a menu item is invoked, not too bad.
Fixed problem with ExitCell event. When suggestion was up and user exited cell,
upon execution of the OnExit event, the cell did not contain the complete
Also, the AutoAcceptSuggestion property was in place, but was never being checked,
in effect making no difference whether it was set to Tru or False. That has been
fixed in this version.
The CreateColumns method is now protected and must be called by components
derived from THyperGrid in their constructor as such:
constructor THyperGridDerived.Create( AOwner );
inherited Create( AOwner );
end; Also, fixed a bug with Parentage and the tip window, so that it will not appear
unless the grid has a valid parent.
Added Clear and ClearRange methods, which can be used to clear a specific range
of cells with empty strings. ClearRange takes two arguments, Topleft and
BottomRight, which are both TGridCoord's. Fixed some minor bugs with cell hints. There is a drawing problem with auto suggestion tool-tip windows, I fixed it by
hiding and re-showing the tool-tip window for now.
Added some entries to the HyperFAQ document. Added public function
GridColumnForColumnObject, which returns the actual grid
column number for a given column object. It returns -1 if the column object is
not found, is nil, or is not visible. Otherwise, it returns the grid column
index for that object. Added a published string property named ColumnRegistryKeys. If this property is
non-blank, the grid will save its column widths to the
HKEY_CURRENT_USER\<the given key> registry key when it exits, and it will restore
them when it is created. Glitches: If there are columns with the same names, their
widths will be over-written. Added two public methods SaveColumnWidthsToRegistryKey and LoadColumnWidthsFromRegistryKey
They both take a string key as an argument and if the argument is non-blank, will
do the appropriate action. The property above is implemented as a call to
LoadColumnWidthsFromRegistryKey( ColumnsRegistryKey ) in the Loaded method and a call
to SaveColumnWidthsToRegistryKey( ColumnsRegistryKey ) in the grid's destructor. Added new OnEnterCell and OnExitCell events. Pretty much self-explanatory. Default row height is now 20 pixels. THyperGrid is now derived from a new component called ThgHintGrid, which is in
turn derived from TStringGrid. This was done to facilitate the implementation
of cell tool tips. ThgHintGrid adds one published property and one event.
The event is OnShowCellHint, and is triggered before a hint is displayed for a
given cell. The event allows you to specify the actual hint text for the given
cell and gives you an opportunity to change the top-left corner of the hint
window. If you return an empty Hint string, no hint will be displayed for the
cell, which is the default. The new property called "HintFollowsMouse"
determines when the hint is displayed. The default of true causes the hint to
be displayed when the mouse enters a cell and to stay up until the mouse leaves
the cell, regardless of whether the grid has focus or not. This behavior is
similar to Excel's cell comment. When HintFollowsMouse is False, the hint is only
displayed when the grid has focus and it follows the focused cell, regardless of
where the mouse is. The protected function HgMouseCoord was moved from THyperGrid up to ThgHintGrid. Added property called "AutoAcceptSuggestion" When set to true, a suggestion is
automatically accepted when the cell is exited, otherwise, the user has to
explicitly hit the enter key to accept the suggestion.
Added some entries to the HyperFAQ document.
Following was added in Version 1.1, but finalized in Version
Added the OnGetCellImage event. The event is declared as
ThgOnGetCellImage = procedure( Sender : TObject; ACol , ARow , HeadingIndex : Longint;
var PictureOrImageList : TObject; var ImageIndex : Integer;
var Position : ThgImagePosition; var HAlign : TAlignment;
var VAlign : ThgVAlignment; var Margin : Integer ) of object;
It is fired before any cell is drawn. You can 1) set PictureOrImageList to point to a
2) set PictureOrImageList to point to a TImageList and supply an Image Index. ACol - column
ARow - row
HeadingIndex - heading index or -1 if not a heading
position - ThgImagePosition = ( hgipLeft , hgipRight , hgipTop , hgipBottom )
where the image will be with respect to the text and or edit.
HAlign - horizontal alignment, only used if position is hgipTop or hgipBottom
VAlign - vertical alignment, only used if position is hgipLeft or hgipRight
Margin - pixels, margin around image, default is 2
Auto adjust of row height was cutting off part of the last line of text.
Auto column width adjust was doing likewise, fixed it. When row height auto adjust was
turned on, the row adjustment slider in the
property editor could cause the component to enter an infinite loop of
messages. Turned auto-adjust off at design time. Small adjustments to text margins. Decreased vertical text margin by 2. Small adjustments to bevels, center bevel is only drawn when there is an
inner bevel. So, outer bevel only will occupy 1 pixel, inner bevel only
will occupy 2 and both bevels will occupy 3. Added design time column width control. Added About dialog to Author property editor. Added edit with row height value. Property editor now verifies that there exists at least one visible column
before allowing OK or Apply. Auto-suggest was not refreshing properly so it appeared to suggest the wrong
item. Fixed. Columns list box in property editor was replaced with a list view to allow
in-place editing and to solve some problems with the column name edit box,
which has been removed. Added Duplicate button to property editor, which creates a new column and gives
it all the attributes of the selected column. Added design time column width edit box, to allow entry of specific column
width. Moved ReadOnly check box to front page. Added OnGetReadOnly event that allows the user to make specific cells read-only. The OnButtonClick event was previously defined as a TNotifyEvnt, which did not
provide the column and row indexes of the button. I modified it to include
Col and Row parameters. Created a helper class which can maintain a list of col and row pairs. It is
called ThgCellList and resides in HgGlobal. It allows insertion, removal, and
"contains" testing of col and row pairs. This can be useful for maintaining
a list of cells with a particular state. Added public methods SelectEntireRow and SelectEntireColumn, self explanatory.
Make sure goEditing is False for them to work. Added public methods InvalidateRow and InvalidateColumn, which calculate the
rectangle for the row or column and invalidate it, causing it to be redrawn,
idependent of the rest of the grid. The OnDrawCell event was not being called. It is now called after HyperGrid
draws each cell, so it can be used to re-draw a cell. Added public class function VersionString that returns THyperGrid's current
version in string form. The in-place edit now allows multiple lines of text to be edited, that is, it
is a multi-line edit. This forced me to change the keyboard shortcut for
activating a cell's button. To activate the button in a cell, you now use
Shift-Enter, to enter a carriage return in the edit box, you use Ctrl-Enter.
To drop down the combo box in the cell, use Alt-Down arrow. The enumeration ThgVAlignment was changed to
ThgVAlignment = ( hgvaTop , hgvaCenter , hgvaBottom );
The 'hg' was added in front for consistency.