Contents
Edit Grid Component

Properties   Methods    Events    Registration

Units

UEdGrid.pas

TEditGrid is derived from TStringGrid. The edit grid is capabale of showing controls derived from TWinControl, including TEdit, TListBox, TComboBox, TSpinEdit, Tmemo, TCheckBox, and TMaskEdit.  The relationship between the Cell and the control is similar to that of the InplaceEdit control Delphi displays over string grids already.

When the cell loses focus by clicking on another cell or scrolling the value in the control is written to theunderlying cell. TEditGrid is capable of deciphering control vaues, like a check in a TCheckBox to a string True or False. True and False values may be represented in any fashion you want: True or False, Yes or No, On or Off or anything.

There are conversion properties so cell contents can be read as integers, floating point numbers, strings, or date and times.

You may specify individual cell fonts. You may hide and show individual columns and rows, and you can choose row shading, where you set the intervals between shaded rows.

For Help on Help, Press F1


Properties

AsBoolean

AsDateTime

AsFloat

AsInteger

AsString

DisplayFalse

DisplayTrue

Fonts

ShadeColor

ShadeModulo

ShadeRow


Methods

Create

Destroy

DisplayControl

HideCol

HideRow

ShowCol

ShowRow


Events

Useful Events


Registration

Contact

TEditGrid is shareware. Register On-line with GO SWREG on CompuServe, registration ID (pending). Or send a check or money order for $29.95 plus $2.95 for shipping and handling to:

Software Conceptions, Inc

Attn: Shareware Department

4352 Dobie  Rd

Okemos, MI 48864

Registered users are entitled to support and a password which enables you to unzip the source code. Software Conceptions is an Association of Shareware Professionals member.


Contact

 1996. All Rights Reserved.

By Paul Kimmel. Okemos, MI USA

Registered users may contact the author at 70353,2711 on CompuServe.


DisplayFalse

See Also 	Example

Applies To

TEditGrid

Declaration

Property  DisplayFalse : String;

Description

DisplayFalse is the string value displayed in the TEditGrid to represent a False value for a CheckBox. If DisplayFalse if No then an unchecked CheckBox is represented in the underlying grid as No.

By default DisplayFalse := False;


DisplayTrue

See Also 	Example

Applies To

EditGrid

Declarations

Property  DisplayTrue : String;

Definitions

The DisplayTrue property defaults to True. You can set any string to represent True. When a CheckBox is displayed in a cell, this property is used to convert the state of the TCheckBox from Checked to a string.


ShadeColor

See Also 	Example

Applies To

EditGrid

Declarations

Property ShadeColor : TColor;

Definitions

The ShadeColor is used to paint shaded rows. ShadeRow must be True, whcih is the default. The number of white (or defaalt color) rows is determined by the ShadeModulo value.

You can use row shading instead of or in addition to grid lines.


ShadeModulo

See Also 	Example

Applies To

EditGrid

Declarations

Property ShadeModulo : Integer;

Definitions

The ShadeModulo value determines the number of rows between row shading. (See ShadeRow  and ShadeColor to add row shading.)


ShadeRow

See Also 	Example

Applies To

EditGrid

Declarations

Property ShadeRow : Boolean;

Definitions

The ShadeRow value defaults to True. Shading will skip ShadeModulo  - 1 rows before painting the shaded row. Skipped rows are painted with the Grid Color value.


Example
Examples

EditGrid1.DisplayFalse := No;   { Will convert unchecked check boxes to No in grid. }

EditGrid1.DispayTrue := True;   { Will convert checked check boxes to Yes in grid. }

EditGrid1.ShadeColor := clNavy; { Shaded rows are displayed with Navy background. }

EditGrid1.ShadeRow := True;      { Rows will be shaded alternately. }

EditGrid1.ShadeModulo := 3;       { Every third row will be shaded with the shade color. }

EditGrid1.AsDateTime[5,1] := Now + 2; { Add two days to current date and store in cell. }

EditGrid1.AsFloat[1,1] := 3.14159;  { Store floating point numbers in the cells. }

if( EditGrid1.AsBoolean[3,2] ) then { Test cells as Boolean directly. }

with EditGrid do

AsInteger[Col, Row] := 5 * 3;  { Store integral values directly. }

EditGrid1.Fonts[ EditGrid1.Col, EditGrid1.Row] := Parent.Font;   { Store individual fonts in any cell/ }


AsDateTime

See Also 	Example

Applies To

EditGrid

Declarations

Property AsDateTime[Col, Row : Integer] : TDateTime;

Definitions

Returns the cell value converting the string representation to a TDateTime value. If the cell value is not a valid TDateTime then an EConvertError  exception.


AsFloat

See Also 	Example

Applies To

EditGrid

Declarations

Property  AsFloat[Col, Row : Integer] : Double;

Definitions

Converts the cell string value to a double precision number. If the string is not a valid floating point  string then an EConvertError .


AsBoolean

See Also 	Example

Applies To

EditGrid

Declarations

Property  AsBoolean[Col, Row : Integer] : Boolean;

Definitions

Converts the cell string value to a Boolean value. If the string is not a valid Boolean string then an EConvertError .


AsInteger

See Also 	Example

Applies To

EditGrid

Declarations

Property  AsInteger[Col, Row : Integer] : Longint;

Definitions

Converts the cell string value to a Longint number. If the string is not a valid integer  string then an EConvertError .


AsString

See Also 	Example

Applies To

EditGrid

Declarations

Property  AsString[Col, Row : Integer] : String;

Definitions

Works just like accessing the Cells property of a TStrinGrid. AsString was provided for completeness but there are no added advantages.


Fonts

See Also 	Example

Applies To

EditGrid

Declarations

Property Fonts[Col,Row]  : Tfont;

Definitions

Use the fonts property to associate TFont  values with any or each cell of the grid. (This property does not use the Objects property; it maintains a separate list.)

A deep copy is performed of the Font, therefore you do not need to keep any font objects around after they were used to initialize the cell.


DisplayControl

See Also 	Examples

Applies To

EditGrid

Declarations

Procedure DisplayControl( Control : TWinControl );

Definitions

Use DisplayControl to display a control over the current cell. Valid controls are TEdit, TMaskEdit, TComboBox, TListBox, TMemo, TCheckBox, and TSpinEdit controls. Selecting a new cell makes the control invisible. The grid does not actually parent the control so you or the original allocater will be responsible for freeing the control.

The relationshiop between the cell and the control is the underlying cell gets its string value from the control. TEditGrid can even convert CheckBox states back and forth from string to checked state.


Create

See Also 	Examples

Applies To

EditGrid

Declarations

Constructor Create( AOwner: TComponent) ; override;

Definitions

This constructor calls the parent constructor and then performs additional construction.


Destroy

See Also 	Examples

Applies To

EditGrid

Declarations

Destructor Destroy; override;

Definitions

You never need to call this method directly. Call Free instead.


HideCol

See Also 	Examples

Applies To

EditGrid

Declarations

Procedure HideCol( Const Col : Integer );

Definitions

Use the HideCol method to hide the column number in the Col parameter. If Col is invalid then this method throws a silent Exception .

The effect of a hidden column is contrived by making the ColumnWidth = 2. Use ShowCol to make the column visible. The DefaultColWidth is used to set the column width when unhiding the column.


HideRow

See Also 	Examples

Applies To

EditGrid

Declarations

Procedure HideRow( Const Row : Integer );

Definitions

The HideRow procedure makes the RowHeight = 2. It leaves enough space to select the Row or know that it exists. Call ShowRow to make the row visible. Throughs a silent exception if the Row does not exist.


ShowCol

See Also 	Examples

Applies To

EditGrid

Declarations

Procedure ShowCol( Const Col : Integer);

Definitions

The ShowCol method returns a hidden column to the DefaultColWidth . If the column does not exist this method handles a silent exception.


ShowRow

See Also 	Examples

Applies To

EditGrid

Declarations

Procedure ShowRowl( Const Row : Integer);

Definitions

The ShowRow method returns a hidden row to the DefaultRowHeight . It throws a silent exception if the row doesnt exist.


See Also

Create

Destroy

DisplayControl

HideCol

HideRow

ShowCol

ShowRow


Examples

EditGrid := TEditGrid.Create(Self);	{ Instantiate an edit grid component. }

EditGrid.Free;	{ Free calls destroy. It is better to call Free. }

Procedure TForm1.Button1Click( Sender : TObject  );

begin

EditGrid1.DisplayControl( CheckBox1 );

{ Insert a checkbox in the grid current col/row. }

end;

EditGrid1.HideCol( 3 );	{ Hides column 3 }

EditGrid1.ShowCol( 3 );	{ Show Column 3 }

EditGrid1.HideRow( 4 );	{ Hides Row 4 }

EditGrid1.ShowRow( 4 );	{ Sets RowHeight to default row height. }


See Also

AsBoolean

AsDateTime

AsFloat

AsInteger

AsString

DisplayFalse

DisplayTrue

Fonts

ShadeColor

ShadeModulo

ShadeRow


Useful Events

The OnDrawCell  event can be useful in adding custom drawing to the grid cells/ For instance you could draw icons on the canvas within the cells TRect.

OnSelectCell events can be caught to add controls to the grid. Use the Col and Row arguments to determine where the control will be placed.

The OnClick event is the event we suggest you use to determine when to add controls to the grid cells. Use DisplayControl to add controls like TListBox, TCheckBox, TComboBox, TSpinEdit, TMaskEdit, and Tmemo controls to an individual grid cell.