Class TDlgColumnVisible (unit Gridutil)

Inherits from

TForm

Constructors



Functions

procedure CheckBoxClick(Sender: TObject);

The private CheckBoxClick method changes the visibility in the grid of the data field that is associated with the checkbox that has just been clicked by the user.

procedure FormCreate(Sender: TObject);

The FormCreate handler sets some default values for the properties.

procedure FormDestroy(Sender: TObject);

The FormDestroy handler cleans up the TList and TStringList objects that were created in the FromCreate event

procedure FormShow(Sender: TObject);

Now loop around copying the visibility etc.

procedure AddCheck( descript, fieldname: string);

Public declarations

The public AddCheck method adds a checkbox to the editor form and then updates the coordinates for the next checkbox that will be added.


procedure Clear;

The public Clear method resets the dialog for re-initialization by a new series of calls to the AddCheck method.

function Run( Sources: array of TDataSource) : TModalResult;

The Run function is the public method that actually shows the visibility editor dialog.

function GetDataSource : TDataSource;

The datasource property of the column visibility editor form is equal to the first datasource that was passed in the argument list for the Run method.

procedure SetCols( Value: integer);

The SetCols property sets the number of columns to any value between 1 and 4 and adjusts the width of the editor form.

procedure SetItemHeight( Value : integer);

The itemheight property can be set in the interval 20 to 100 pixels.

procedure SetItemWidth( Value : integer);

The ItemWidth property can be set in the interval 5 to 200 pixels.

Properties

property Cols : integer


property ItemHeight : integer


property ItemWidth : integer


property DataSource : TDataSource


Events

Variables

ButtonClose : TBitBtn;


ButtonHelp : TBitBtn;


PanelButtons : TPanel;


PanelClient : TPanel;


AllSources : TList;


Fcols : integer;


FieldNames : TStringList;


FItemHeight : integer;


FItemWidth : integer;


x : integer;

Private declarations

y : integer;



Constructors


Functions


procedure CheckBoxClick(Sender: TObject);

The private CheckBoxClick method changes the visibility in the grid of the data field that is associated with the checkbox that has just been clicked by the user. The Tag value of the clicked checkbox is also the index of the associated fieldname in the FieldNames stringlist of the editor dialog. The visibility is switched in all of the datasources that have been passed in the open array argument to the Run method. This allows you to control visibility of columns in more that one TDBGrid at the same time (I needed this feature myself, so I built it in ) You are not supposed to call this method from your own form. Instead, this method is installed as an event handler for all the checkbox components that are added with calls to the (public) AddCheck method.


procedure FormCreate(Sender: TObject);

The FormCreate handler sets some default values for the properties. It also creates the stringlist that is used to store the fieldname information added by repeated calls to the AddCheck method, and the list that is used to store all affected datasources passed in the open array argument to the Run method.


procedure FormDestroy(Sender: TObject);

The FormDestroy handler cleans up the TList and TStringList objects that were created in the FromCreate event


procedure FormShow(Sender: TObject);

Now loop around copying the visibility etc. Assume table field layout is exactly the same for i & o If not this will yield invalid layout so we may as well raise the exception about field index out of range


procedure AddCheck( descript, fieldname: string);

Public declarations

The public AddCheck method adds a checkbox to the editor form and then updates the coordinates for the next checkbox that will be added. The idea is that before you call the Run method, you call AddCheck once for each column in the grid for which you want the visibility to be edited. The first argument becomes the caption of the checkbox, the second argument is the FieldName of the field for which you want the visibility to be edited. The checkboxes are added to the form starting in the upper-left corner. I you have more than one column of checkboxes, adding goes from left to right until it is time for a new line. The height of the editor dialog is adjusted automatically for each new line of checkboxes added.


procedure Clear;

The public Clear method resets the dialog for re-initialization by a new series of calls to the AddCheck method. All old checkboxes are removed from the dialog and the height of the dialog and the starting point for AddCheck are reset to default values.


function Run( Sources: array of TDataSource) : TModalResult;

The Run function is the public method that actually shows the visibility editor dialog. You should first setup the dialog by calling its Clear method once and its AddCheck method repeatedly (for everyfield associated with a grid column for which you want to edit visibility). During a Run, all the datasources passed to the open array argument are stored in the AllSources TList. This list is used in the private CheckBoxClick method to change visibility in all affected grids as soon as a checkbox is clicked.


function GetDataSource : TDataSource;

The datasource property of the column visibility editor form is equal to the first datasource that was passed in the argument list for the Run method. It is a run-time and read-only property.


procedure SetCols( Value: integer);

The SetCols property sets the number of columns to any value between 1 and 4 and adjusts the width of the editor form. The number of columns determines how many columns of checkboxes are shown in the editor form. Checkboxes are added to the form left-to-right. Like all other properties of the editor, it is run-time only.


procedure SetItemHeight( Value : integer);

The itemheight property can be set in the interval 20 to 100 pixels. It represents the vertical distance between the tops of the checbox components. An additional gap of YGap pixels is taken into account. Like all other properties of the editor, it is run-time only.


procedure SetItemWidth( Value : integer);

The ItemWidth property can be set in the interval 5 to 200 pixels. It represents the width of the checkbox components. An additional gap of XGap pixels is taken into account when more than one column of checkboxes is shown. Like all other properties of the editor, it is run-time only.


Properties


property Cols : integer


property ItemHeight : integer


property ItemWidth : integer


property DataSource : TDataSource


Events


Variables


ButtonClose : TBitBtn;


ButtonHelp : TBitBtn;


PanelButtons : TPanel;


PanelClient : TPanel;


AllSources : TList;


Fcols : integer;


FieldNames : TStringList;


FItemHeight : integer;


FItemWidth : integer;


x : integer;

Private declarations


y : integer;