Thema: Delphi Indexfehler ??

Einzelnen Beitrag anzeigen

marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#5

Re: Indexfehler ??

  Alt 28. Nov 2007, 09:28
Hallo Fritz,

vom Prinzip her solltest du folgende Struktur verwenden können:

Delphi-Quellcode:
unit DemoFrm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, ABSMain, Grids, DBGrids, ComCtrls;

type
  TDemoForm = class(TForm)
    TreeView: TTreeView;
    DBGrid: TDBGrid;
    ABSDatabase: TABSDatabase;
    ABSTable: TABSTable;
    DataSource: TDataSource;
    procedure TreeViewChange(Sender: TObject; Node: TTreeNode);
    procedure DBGridTitleClick(Column: TColumn);
  private
    procedure SwitchTable(const tblName: string);
    procedure SwitchIndex(const idxName: string);
  end;

var
  DemoForm: TDemoForm;

implementation

{$R *.dfm}

uses
  StrUtils;

procedure TDemoForm.SwitchIndex(const idxName: string);
begin
  with AbsTable do
  if not SameText(idxName, IndexFieldNames) then
  begin
    DisableControls;
    try
      IndexFieldNames := idxName;
    finally
      EnableControls;
    end;
  end;
end;

procedure TDemoForm.SwitchTable(const tblName: string);
begin
  with AbsTable do
  if not SameText(tblName, TableName) then
  begin
    DisableControls;
    try
      if Active then Close;
      SwitchIndex('');
      TableName := tblName;
      if TableName <> 'then Open;
    finally
      EnableControls;
    end;
  end;
end;

procedure TDemoForm.TreeViewChange(Sender: TObject; Node: TTreeNode);
begin
  SwitchTable(IfThen(Assigned(Node), Node.Text));
end;

procedure TDemoForm.DBGridTitleClick(Column: TColumn);
begin
  SwitchIndex(Column.FieldName);
end;

end.
Getippt und nicht getestet.

Freundliche Grüße
  Mit Zitat antworten Zitat