Einzelnen Beitrag anzeigen

Benutzerbild von haentschman
haentschman

Registriert seit: 24. Okt 2006
Ort: Seifhennersdorf / Sachsen
5.297 Beiträge
 
Delphi 12 Athens
 
#24

AW: VirtualTreeView Editfelder, ComboBox und andere

  Alt 3. Apr 2016, 06:19
Moin...

aktuell habe ich noch eine TAdvListview drunter. Die Umstellung auf VT steht auf der TodoListe.

Vieleicht können dir die Brocken ein paar Ansätze liefern.

1. Positionierung Form
Delphi-Quellcode:
class procedure TdTools.SetEditorPositions(ParentListView: TAdvListView; Editor: TForm);
var
  I: Integer;
  CurrentPoint: TPoint;
  CurrentTop: Integer;
begin
  CurrentPoint:= ParentListview.ClientToScreen(Point(30,0)); // 30 = um erste Spalte eingerückt
  CurrentTop:= CurrentPoint.Y + ParentListview.Selected.Top; // beim Listview hat der selektierte Eintrag Top... VT ?
  if (CurrentTop + Editor.Height) > Screen.WorkAreaHeight then // klappt den Editor entweder nach unten oder nach oben wenn er nicht mehr auf den Screen paßt
  begin
    CurrentTop:= (CurrentTop + ParentListview.ItemHeight) - Editor.Height + 4;
  end;
  Editor.Top:= CurrentTop;
  Editor.Left:= CurrentPoint.X;
  Editor.Width:= 0;
  for I := 1 to ParentListView.Columns.Count -1 do
  begin
    Editor.Width:= Editor.Width + ParentListView.Column[I].Width;
  end;
  Editor.Width:= Editor.Width + conEditorOffsetWidth; // Offset = Feinjustierung für Liniendicke des Grids
end;
2. Im constructor bekommt der Editor(Form) den Parent mit:
Delphi-Quellcode:
constructor TfoInlineEditorProfiles.Create(Preferences: TdVAPreferences; Database: IdVA_Database; Profile: TProfile; ParentListview: TAdvListView);
begin
  inherited Create(nil);
  FLogic:= TInlineEditorProfile.Create(Preferences, Database, Profile); // die BL zum Form
  FLogic.OnGetProfileGroups:= DoOnGetProfileGroups;
  FLogic.OnGetParameters:= DoOnGetParameters;
  FLogic.GetData;

  pgrProfileProperties.ActivePageIndex:= 0;
  tvDevices.Width:= FLogic.Preferences.PositionsVA.SplitterEditorProfiles;
  TdTools.SetControlPosition(ParentListview, 1, True, edtProfileNameLong, daLeft); // Positionierung der 1. Reihe auf die Spalten
  TdTools.SetControlPosition(ParentListview, 2, True, cbbProfileGroup, daLeft);
  TdTools.SetControlPosition(ParentListview, 3, True, cbbBatchJob, daLeft);
  TdTools.SetControlPosition(ParentListview, 4, True, cbbVisualType, daLeft);
  TdTools.SetControlPosition(ParentListview, 5, True, cbbActive, daLeft);
  if FLogic.Preferences.PositionsVA.SplitterEditorProfiles > pnlDevices.Width then
  begin
    pnlDevices.Width:= FLogic.Preferences.PositionsVA.SplitterEditorProfiles;
  end
  else
  begin
    FLogic.Preferences.PositionsVA.SplitterEditorProfiles:= pnlDevices.Width;
  end;
end;
3. Positionierung auf Spalten
Delphi-Quellcode:
class procedure TdTools.SetControlPosition(ParentListView: TAdvListView; ColumnIndex: Integer; SetWidth: Boolean; Control: TControl; Align: TdAlign);
var
  I: Integer;
begin
  // Todo: Berücksichtigung wenn Control größer als Column
  Control.Left:= 0;

  for I := 1 to ColumnIndex do
  begin
    if I = 1 then
    begin
      Control.Left:= Control.Left;
    end
    else
    begin
      Control.Left:= Control.Left + ParentListView.Column[I - 1].Width;
    end;
    if (I = ColumnIndex) and not (ColumnIndex = 1) then
    begin
      Control.Left:= Control.Left - 1;
    end;
  end;

  if SetWidth then
  begin
    Control.Width:= ParentListView.Column[ColumnIndex].Width + 1;
    if Control is TAdvSmoothComboBox then
    begin
      TAdvSmoothComboBox(Control).DropDownWidth:= Control.Width;
    end;
  end;

  case Align of
    daLeft: Control.Left:= Control.Left;
    daRight: Control.Left:= Control.Left + (ParentListView.Column[ColumnIndex].Width - Control.Width);
    daCenter: Control.Left:= Control.Left + ((ParentListView.Column[ColumnIndex].Width - Control.Width) div 2);
  end;
end;
  Mit Zitat antworten Zitat