fuer dieses Hilf auf Deutsch E-Mail mich.

This Evaluation version is complete but only runs in the Delphi IDE.  If you
use this evaluation version in a program and send it out the MultiDBGrid
will not do multi-selection.  Registration includes full source code,
(free upgrades and Tech Support through E-Mail only).  Suggestions welcomed!

Send Money Order or Check drawn on U.S. Bank to:
Michael Messerschmidt
105 N. 44th Street
Harrisburg, Pa. 17111-2622
U.S.A.

if I can E-Mail to you: Registration is $5
if I must Mail to you in the U.S. $7
if I must Mail outside the U.S. $10.

The MultiDBGrid is for use with DBase and Paradox files.
The MultiDBGrid Component is a descendent of the DBGrid and for use with
DBase and Paradox files.  You can do everything with the MultiDBGrid that
you can do with the DBGrid.  The MultiDBGrid gives you the functionality of
a listbox--you can select multiple items at once to either delete, drag and
drop or just access the data for those records selected.  The new published
property MultiSelect which defaults to true allows for this added
functionality.  Setting this property to false doesn't allow multiple
selections.

You will need to place the following two files in your library path:
(MULTGRID.DCU and MULTGRID.DCR).  Now add the TMultiDBGrid Component to
your Component library by following the directions in your Delphi User's
Guide.  The Component will be added to the Data Controls palette page.

if MultiSelect is true then:
a left mouse click will select a record.  If that record was already
selected, it will be de-selected.  If you had a range or group of records
selected, they will all be de-selected and only the new record selected.
If you hold down the Control Key and click the left mouse button a record
will be added to the select list.  If the record was already selected, it
will be de-selected.  When you add a record with either the Left mouse
button or the Left mouse button and the Control Key you set that record as
an ancor.  Selecting a record now with the Left mouse button and the Shift
key will select all records from the ancor to the current record.

new properties are:  MultiSelect
                     ForwardSelect
                     AutoRemove

Some key new methods are:  function GetSelRecord : Boolean;
                           function SelCount : Integer;
                           procedure DelRec;
                           procedure ResetList;

property MultiSelect : Boolean;
this property defaults to True.  Setting it to false, and you have a normal
DBGrid with no multiselection capability.

property ForwardSelect : Boolean;
this property defaults to True.  When this property is true you are going
forward in the list of selected records and when it is false you are going
backwards in the list.  Whenever deleting Paradox records this must be set
to FALSE.  If you forget to set it False when deleting Paradox records, no
records will be deleted to insure database integrity.  With Paradox, if you
must access the list in the forward direction AND must delete the records,
you will have to run through your list first with AutoRemove False and
ForwardSelect True;  Then run through your list again with ForwardSelect
False to delete the records.

property AutoRemove : Boolean;
this property defaults to True.  When this property is true your selected
list will be automatically handled and you can only run through your list
of selected records once.  All of the selected records will be de-selected
if they were not deleted after your GetSelRecord Loop.  If this property is
false you can run through your list more than one time.  All of the selected
records will stay selected if they were not deleted after your GetSelRecord
Loop.  Unless there is a need to run through your list more than one time,
leave this set to True.

function SelCount : Integer;
this method returns the number of selected records.  You only need to call
this function if you want to find the number of selected records.  Not
checking for the number of selected records before calling GetSelRecord
is not a problem because GetSelRecord will return false if there are no
records selected or it couldn't read a record.

function GetSelRecord : Boolean;
this method reads a selected record's data.  This method will return false
if there are no records selected or a record could not be read.

procedure DelRec;
this method deletes a selected record.  You must call the GetSelRecord
method before the DelRec method.  If you don't call the GetSelRecord method
before DelRec you will not get an error; however, no record will be deleted.
Use this method to delete selected records.  DO NOT use Table.Delete!

procedure ResetList;
this method MUST be called before and after you do a GetSelRecord Loop.

**** IMPORTANT ****
NOTE: You MUST call ResetList before your loop.  You MUST call both
      TABLE.Refresh AND ResetList after your GetSelRecord Loop.  Table is
      the table that MultiDBGrid is attached to through it's datasource
      property. DO NOT use Table.Delete to delete records!  Keep in mind
      if you change the default settings of properties at run time that
      your user can use this component more than once in the program.  So
      make sure to do ResetList before and after loops and don't take for
      granted the properties are set how you think they will be.  If you
      are doing a dual loop--say for Paradox and set ForwardSelect to False
      in the second loop... If the user does this routine again unless you
      have manuall set ForwardSelect to True before the first loop... it is
      now False!

SCENARIOS:
DBase : no restrictions, you can delete records with FowardSelect True or
        False.

Paradox : if you need to do more than delete a record AND you need to do it
          in Forward order:  you must loop through the list doing what you
          need to do first with AutoRemove False and ForwardSelect True;
          then to actually delete the records you must loop through again
          with ForwardSelect False.

          You cannot do any posting of records that changes the index order.
          If you do, your selected list no longer points to the correct
          records.



the following is an example of deleting all the selected records when a
button is clicked or dragging and dropping all selected records firstname
fields to a listbox.


procedure TForm1.Button1Click(Sender: TObject);
begin
  if MultiDBGrid1.SelCount <= 0 then MessageDlg('Nothing selected',
                                                 mtInformation,[mbOk],0)
  else
  try
    MultiDBGrid1.ResetList;

    while MultiDBGrid1.GetSelRecord do MultiDBGrid1.DelRec;
  finally
  table1.refresh;
  MultiDBGrid1.ResetList;
  end;
end;


procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept := Source is TMultiDBGrid;
end;

procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
  if Source is TMultiDBGrid then
  try
  MultiDBGrid1.ResetList;

  while TMultiDBGrid(Source).GetSelRecord do

 >  with TMultiDBGrid(Source).DataSource.DataSet do
|  TListBox(Sender).Items.Add(FieldByName('firstname').AsString);
|
| { both the two above lines and the following line do the same thing }
| { you can use which ever way you prefer to code. }
|
|
 > TListBox(Sender).Items.Add(Table1.FieldByName('firstname').AsString);

  finally
  table1.refresh;
  MultiDBGrid1.ResetList;
  end;
end;


the following is an example of situation in Paradox where you want to drag
and drop your selected list into a listbox and delete all the selected
records.  If you didn't care or need the records to be in Forward order
you could do this with one loop and ForwardSelect set to False.


procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept := Source is TMultiDBGrid;
end;

procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
  if Source is TMultiDBGrid then
  try
  MultiDBGrid1.ResetList;
  MultiDBGrid1.AutoRemove := False;

  while TMultiDBGrid(Source).GetSelRecord do

 >  with TMultiDBGrid(Source).DataSource.DataSet do
|  TListBox(Sender).Items.Add(FieldByName('firstname').AsString);
|
| { both the two above lines and the following line do the same thing }
| { you can use which ever way you prefer to code. }
|
|
 > TListBox(Sender).Items.Add(Table1.FieldByName('firstname').AsString);


  MultiDBGrid1.ResetList;
  MultiDBGrid1.ForwardSelect := False;

  while MultiDBGrid1.GetSelRecord do MultiDBGrid1.DelRec;

  finally
  table1.refresh;
  MultiDBGrid1.ResetList;
  end;
end;
