Grid Changes
A number of enhancements and fixes have been made to the grid classes (Grid, dbList, dbGrid). The information provided here encompasses the enhancements that provide new grid capabilities. You should also review the fixed bug list to see what has been fixed.
Horizontal Scrolling Improvements
One of the most frequently made requests for Grid, dbGrid, and dbList improvements is to enhance their horizontal scrolling behavior. The logic for horizontal scrolling has been completely rewritten and is much improved.
No programming changes are required to use the new horizontal scroll bar behaviors. All changes were made to the DataFlex runtime. Therefore, any application running under 8.2 will immediately benefit from these changes.
Prior to 8.2, the horizontal scrolling of grids was tied into the item_change mechanism. This limitation resulted in the following types of reports:
- You cannot scroll left and right without causing item focus changes.
- You cannot scroll into a shadowed item because it could not become the current item.
- If the rightmost columns were shadowed, you could not scroll and see them at all.
- If the grid did not have the focus, horizontal scrolling was ignored.
- If the grid was read-only or shadowed, horizontal scrolling was impossible.
- Horizontal scrolling by clicking on the scroll bar arrows would stop if the next column were disabled.
All this made horizontal scroll bar behavior appear quite inconsistent.
Horizontal scrolling now operates without any object focus or item focus change or requirement. Instead of changing items, you are now just panning left and right. The minimum scroll increment is a column (similar to how spreadsheets work). You can view any column you wish without changing the current item. If you click on a cell that is not the current item, the grid makes all the necessary changes to view and edit that new cell item. If, after a scroll, you start typing, the grid will, as needed, snap back and display your changes in the original current cell.
By not binding horizontal scrolling to current-item change, you can now scroll and view any column (enabled or disabled), and you can do this whether the grid has the focus or some other object has focus. Scrolling the grid does not change the current focus and it does not change the current item.
This change is best seen by looking at the order entry example. Make the grid column much wider so that horizontal scrolling is required. You should find the newly designed behaviors to be much easier to use and far more intuitive.
All these changes are supported without requiring any changes in your code. We have provided two new messages to allow you to better control horizontal scrolling.
IsColumnVisible Function
Type: Function
Arguments: integer iColumn
Returns: Boolean
This function can be called to determine if a particular column is visible. You can use this to determine if you need to perform a scroll by sending the DoMakeColumnVisible message.
Procedure CheckCol integer iCol
Boolean bVisible
Get IsColumnVisible iCol to bVisible
If not bVisible ;
Send DoMakeColumnVisible iCol
End_procedure
DoMakeColumnVisible Procedure
Type: Procedure
Arguments: integer iColumn
Sending this message ensures that the passed column number is fully visible. If the column is not visible, the grid will be scrolled as needed to make it so.
Procedure ScrollLeft
Send DoMakeColumnVisible 0
End_Procedure
Procedure ScrollRight
Send DoMakeColumnVisible (item_limit(self) - 0)
End_Procedure
This method is used in objects based on dbGrid and dbList (implemented in the Datalist super-class) to snap the grid back to column zero whenever the message beginning_of_panel is sent to a view. The message beginning_of_panel sends the message OnBeginningOfPanel to all objects. When the dbGrid or dbList receives the message, it does the following:
// Augment to always force the first column to be visible. This will occur during a
// panel's clear or save. It makes sense to restore the column. If you do not want this
// behavior, just cancel it.
Procedure OnBeginningOfPanel
Send DoMakeColumnVisible 0
End_procedure
Mouse Wheel Support
The mouse wheel is now supported in grids. No changes are required to make this work. Scrolling the wheel forward or backward will scroll your list forwards and backwards as expected.
If you wish to create custom mouse wheel behaviors, you can augment the event OnMouseWheel. This message is sent every time a mouse wheel is clicked.
Type: Event
Arguments: integer iClicks, integer iKeys
If iClicks is positive, the wheel is being moved forward (away from you). By default, this is used to scroll towards the top of the list. If iClicks is negative, the wheel is being moved backward (towards you). By default, this is used to scroll down the list.
The iKeys parameter is the Windows bit mask that determines what other keys might have been pressed as you move the mouse wheel. It is not used in the default implementation. Consult the Windows documentation for WM_MouseWheel if you need to use this.
New Color Properties
New color properties have been added to Grids, dbGrids, and dbLists that allow you to control the color of gridlines and disabled cells. These properties, added to the runtime, were introduced in response to developer requests.
Note that the default value of all of these properties provides behavior identical to previous versions of DataFlex.
peGridLineColor Property
Type: Property
Default: clBtnFace
The new property peGridLineColor can be used to change the color of your grid lines. By default, it will appear as clBtnFace, which is the color it has always been. This property is exposed in the Studio.
Disabled Cell Text Color Property
Type: Property
Default: clGrayText
This allows you to select a custom color for disabled cell text. Prior to VDF 8.2, this color was fixed as clGrayText (which remains the default). You may now change this to any text color you wish. This property is exposed in the Studio, although you will not see the effect of the change until you run your application.
peDisabledColor Property
Type: Property
Default: False
Normally, a grid uses the same background color for enabled and disabled cells. In VDF 8.2, you can choose to set a different color for disabled cells by setting the peDisabledColor property. This property color is used only if the pbUseDisabledColor is set to True. When pbUseDisabledColor is set to False (the default), a disabled cell's background color is determined by the Color Property - the same property used to set the enabled cell background color.
The pbUseDisabledColor property also changes the way disabled cells are displayed. When false, the highlight row color will be applied to all cells, enabled and disabled. This is how DataFlex has always behaved. When true, the peDisabledColor takes precedence over the highlight row color.
This property is exposed in the Studio, although you will not see the effect of the change until you run your application.
Disabled Cell Background Color Property
Type: Property
Default: clWindow
This determines the background color of a disabled cell. This color is only applied if the pbUseDisabledColor property is set to true. When false, the Color property is used to set the background color of all cells in the grid.
Because pbUseDisabledColor defaults to false, this new property will have no effect on existing applications until you change that property.
This property is exposed in the Studio, although you will not see the effect of the change until you run your application.