AL_IndexCombo

Top  Previous  Next

unit AL_IndexCombo;

 

interface

 

uses

SysUtils, WinTypes, WinProcs, Messages, Classes, Menus,

Graphics, Controls, Forms, Dialogs, StdCtrls, DB, DBTables, DBF;

 

Type

 

TALIndexCombo = class(TComboBox)

private

   FDataSource: TDataSource;

   procedure SetDataSource(const Value: TDataSource);

public

   constructor Create(AOwner:TComponent);override;

   destructor Destroy;override;

published

   Property DataSource : TDataSource read FDataSource write SetDataSource;

end;

 

implementation

 

{ TALIndexCombo }

 

constructor TALIndexCombo.Create(AOwner: TComponent);

begin

    inherited Create(AOwner);

    FDataSource := nil;

    Clear;

    Text := '';

end;

 

destructor TALIndexCombo.Destroy;

begin

Clear;

inherited;

end;

 

procedure TALIndexCombo.SetDataSource(const Value: TDataSource);

begin

    If Value<>FDataSource then begin

       FDataSource := Value;

       if Value <> Nil then

          If DataSource.DataSet is TTable then begin

             TTable(DataSource.DataSet).DefaultIndex := True;

             GetIndexList(TTable(DataSource.DataSet),Items);

          end;

    end;

end;

 

end.