Einzelnen Beitrag anzeigen

Andreas L.
(Gast)

n/a Beiträge
 
#6

Re: Record in Record - Der linken Seite kann nichts zugewies

  Alt 19. Jan 2010, 13:51
Hier mal mein original Code:
StartupListView.pas
Delphi-Quellcode:
type
  TStartupListViewColumn = record
    Visible: Boolean;
    Text: String;
  end;

  TStartupListViewColumns = record
    Name: TStartupListViewColumn;
    Status: TStartupListViewColumn;
    Command: TStartupListViewColumn;
    Location: TStartupListViewColumn;
    AppName: TStartupListViewColumn;
    AppManufacturer: TStartupListViewColumn;
    AppDescription: TStartupListViewColumn;
    FileName: TStartupListViewColumn;
    Parameters: TStartupListViewColumn;
  end;

  TStartupListView = class(TListView)
  private
    FVisibleColumns: TStartupListViewColumns;
    ...
  protected
    procedure SetVisibleColumns(Value: TStartupListViewColumns);
    procedure UpdateColumns;
    ...
  public
    ...
    property VisibleColumns: TStartupListViewColumns
      read FVisibleColumns write SetVisibleColumns;
  end;

...

procedure TStartupListView.SetVisibleColumns(Value: TStartupListViewColumns);
begin
  FVisibleColumns := Value;
  UpdateColumns;
end;

procedure TStartupListView.UpdateColumns;
begin
  Columns.BeginUpdate;
  try
    Columns.Clear;

    Columns.Add.Caption := FVisibleColumns.Name.Text;

    if FVisibleColumns.Status.Visible then
      Columns.Add.Caption := FVisibleColumns.Status.Text;

    if FVisibleColumns.Command.Visible then
      Columns.Add.Caption := FVisibleColumns.Command.Text;

    if FVisibleColumns.Location.Visible then
      Columns.Add.Caption := FVisibleColumns.Location.Text;

    if FVisibleColumns.AppName.Visible then
      Columns.Add.Caption := FVisibleColumns.AppName.Text;

    if FVisibleColumns.AppManufacturer.Visible then
      Columns.Add.Caption := FVisibleColumns.AppManufacturer.Text;

    if FVisibleColumns.AppDescription.Visible then
      Columns.Add.Caption := FVisibleColumns.AppDescription.Text;

    if FVisibleColumns.FileName.Visible then
      Columns.Add.Caption := FVisibleColumns.FileName.Text;

    if FVisibleColumns.Parameters.Visible then
      Columns.Add.Caption := FVisibleColumns.Parameters.Text;

  finally
    Columns.EndUpdate;
  end;
end;
Hauptunit, TStartupListView wird ganz normal auf die Form gezogen
Delphi-Quellcode:
procedure TfrmManager.ToolButton1Click(Sender: TObject);
begin
  StartupListView1.VisibleColumns.Name.Visible := True;
  StartupListView1.VisibleColumns.Status.Visible := True;
  StartupListView1.VisibleColumns.Command.Visible := True;
  StartupListView1.VisibleColumns.Location.Visible := True;
  StartupListView1.VisibleColumns.AppName.Visible := True;
  StartupListView1.VisibleColumns.AppManufacturer.Visible := True;
  StartupListView1.VisibleColumns.AppDescription.Visible := True;
  StartupListView1.VisibleColumns.FileName.Visible := True;
  StartupListView1.VisibleColumns.Parameters.Visible := True;

  StartupListView1.StartupList := damData.StartupList;
  StartupListView1.Refresh;
end;
Die Meldung wird bei jeden Schreib-Zugriff auf VisibleColumns ausgegeben.

Naja, wenn niemand mehr eine Idee hat, verwende ich halt ne Klasse.
  Mit Zitat antworten Zitat