1. How
I can add the sorted column? You may
do it in a few different ways: {add a new sorted column in list - ascending order} (SMDBGrid.Columns[1] as TSMDBColumn).SortType := stAscending {add a new sorted column in list - descending order} (SMDBGrid.Columns[2] as TSMDBColumn).SortType := stDescending; - as alternative, you may use the SetSortField method for TSMDBGrid SMDBGrid.SetSortField(yourDataset.FindField('OrderNo'), stAscending); |
2.
How I can clear the all sorted columns? You may do it in a few different ways:
|
3.
How I can change a standard TSMDBGrid glyphs (sorted
arrows, indicator symbols etc)? You can run the Image Editor application (or any other resource workshop), open the SMDBGrid.RES file and change the any glyphs. |
4.
How I can change standard strings for messages? In SMCnst.PAS file you can find the any string resource and change it or translate on new language. Now there are 20 languages (see RESOURCES sub-folder in original archive):
If you'll translate the messages to the new language or will modify existing file, send the changed file to me (mshkolnik@scalabium.com) and I shall include it in the new build for public downloading. |
5.
How I can increase the width for Indicator column? For it's necessary to change value of WidthOfIndicator property. Pay attantion to that width cann't be less than 11 (width of indicator in standard TDBGrid). Also if you include a eoCheckBoxSelect flag in ExOptions property for record selecting by checkbox, then minimum value is width of standard checkbox in a current Windows settings. |
6.
How I can display the images in Indicator column? Write the handler for OnGetGlyph event to provide customized drawing for the data in the Indicator column. You can define a glyph that will be displayed. And, of course, this event will be called for each row so you could define the different glyphs for records by your custom condition. Note that the Indicator width will not be automatically increased, if the glyph could not be fit in the cell. You should set the width for Indicator column to fit the all information that will be displayed there (checkbox for record selection, row state glyph etc). In the current version you can assign the bitmap only but in future I plan to add the any graphics (icons, metafile, jpeg etc) |
7.
How I can display the multi-line captions for columns? This feature is supported automatically - when you change a width of any column or add/remove the sorted type in column, width of columns will be recalculate automatically and if it's necessary title height will change! |
8.
I want display the pictures in cells for graphic fields.
How I can do it? Just set a eoDrawGraphicField flag in ExOptions property. |
9. How
I can assign the operations to standard menu items? For each item in standard menu are created events:
All these events are very useful. For example, you can assign a procedure for append record, where you will create a new dialog with controls for every field. And always if your end-user will append the new record, your dialog will be shown. Note that if you not assigned the code for some events then corresponded menu items will be hidden. |
10. Can
I use a standard popup menu and add the custom popup? Yes, of course. When you included the eoStandardPopup flag in ExOptions property, the standard popup will be displayed by right button mouse click. But if you assigned the custom popup in Popup property then the standard popup will be displayed by click in "dropdown" cell only (top left cell: in title row of Indicator column). |
11. I
want to disable the append and/or delete actions in grid To include a eoDisableInsert and/or eoDisableDelete flag in ExOptions property. |
12. Can
I fix some columns? Yes, of course. See the FixedCols property. To customize the color for fixed columns you may in FixedColor property. Also if you want to fix columns, but to save their original attributes, set the eoFixedLikeColumn flag in ExOptions property. |
13.
I want to display a hint for each cell. If
you want to display a hint that contains the full string
(truncated by cell width during view), include the
eoCellHint flag in ExOptions property. PS: if the field value fits in the cell completely (is not truncated), the hint window will be not displayed. |
14.
How can I insert the checkbox in cells? If you included the eoBooleanAsCheckBox flag in ExOptions property, then any boolean field will use the checkbox as standard editor in cell. |
15.
I want to display the dropdown and ellipsis buttons in
cells. If you included the eoShowLookup flag in ExOptions property, then for each columns of every row (if specified the PickList property or ButtonStyle is cbsEllipsis or field is the Lookup-field) will be displayed the buttons (dropdown arrow or ellipsis). You can click on this button and action will be exeuted automatically (dropdown list displayed or assigned event executed) PS: in the standard TDBGrid these buttons displayed only in editor mode. |
16.
My users want to use an Enter key like TAB for column
navigation. Set the eoENTERlikeTAB flag in ExOptions property. |
17. In
standard DBGrid I have the event for data drawing only.
Is there any event for title drawing? Yes, see an OnDrawColumnTitle event. |
18.
I want to draw the rows with different colors. If you want to draw the rows in TSMDBGrid with custom color/font etc, you can do it in a few different ways. The first method is very-very simple: Example 1: procedure TForm1.SMDBGrid1GetCellParams(Sender: TObject; Field: TField; AFont: TFont; var Background: TColor; Highlight: Boolean); begin {if CustNo less than 15, then set a bold font and red color in background} if Assigned(Field) and (UpperCase(Field.FieldName) = 'CUSTNO') then begin if Field.AsInteger < 15 then begin AFont.Style := [fsBold]; Background := clRed; end else begin AFont.Style := []; Background := clWhite; end end end; The second method is: Example 2: procedure TForm1.SMDBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin {if CustNo is 13 and is a second column, then draw image and text after it} if (Table1.FieldByName('CustNo').AsInteger = 13) and (DataCol = 2) then begin SMDBGrid1.Canvas.FillRect(Rect); SMDBGrid1.Canvas.Draw(Rect.Left, Rect.Top, Image1.Picture.Bitmap); SMDBGrid1.Canvas.TextOut(Rect.Left+20, Rect.Top+20, Column.Field.FieldName); end; end; |
19.
I want to change a color for odd rows. You may use the GridStyle property and specitfy there any custom colors for Odd/Even rows or select any from predefined color schemes (price-list, MS Money etc) Also as alternative, you may change the color as I described in previous topic - you can do it in OnGetCellParams or OnDrawColumnCell events. For example: procedure TForm1.SMDBGrid1GetCellParams(Sender: TObject; Field: TField; AFont: TFont; var Background: TColor; Highlight: Boolean); begin if (Table1.RecNo mod 2 = 1) then Background := clRed; end; PS: of course, RecNo is valid for local tables only (Paradox, DBase etc). |
20. How
I can receive the latest news about TSMDBGrid, new builds
and upgrades? If you want to receive the latest news about TSMDBGrid development and new versions/announcements, then:
In this mailing list and newsgroups you can discuss the questions related to my components and/or applications (TSMDBGrid too, of course), receive the latest news about development, suggest the new features, send bug-reports, receive the updates, new versions and bug fixings. Also there you can take the answer on any Delphi programming question. If you want to contact me personally, send a message to mshkolnik@scalabium.com |
Download a lastest version: smcmpnt.zip
Copyrightc 1998-2024, Scalabium
Software. All rights reserved. |
May 13, 2004 |