From 2117e8a35f39587e05907b03755625bb7ff41b79 Mon Sep 17 00:00:00 2001 From: bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Sat, 15 Dec 2012 18:18:18 +0000 Subject: [PATCH] ValEdit: Do not use Columns.Add, it interferes with setting FixedCols := 1 (by adding an extra column in front). git-svn-id: trunk@39552 - --- lcl/valedit.pas | 62 ++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/lcl/valedit.pas b/lcl/valedit.pas index 9d185fd630..a3a12fbe28 100644 --- a/lcl/valedit.pas +++ b/lcl/valedit.pas @@ -266,14 +266,18 @@ begin FStrings.OnChanging:=@StringsChanging; FTitleCaptions := TStringList.Create; TStringList(FTitleCaptions).OnChange := @TitlesChanged; + //Don't use Columns.Add, it interferes with setting FixedCols := 1 (it will then insert an extra column) + { with Columns.Add do Title.Caption := 'Key'; with Columns.Add do begin Title.Caption := 'Value'; DropDownRows := 8; end; - // or: ColCount:=2; -// inherited RowCount := 2; + } + + ColCount:=2; + inherited RowCount := 2; FixedCols := 0; // DefaultColWidth := 150; // DefaultRowHeight := 18; @@ -284,6 +288,7 @@ begin FDisplayOptions := [doColumnTitles, doAutoColResize, doKeyColFixed]; Col := 1; FDropDownRows := 8; + ShowColumnTitles; end; destructor TValueListEditor.Destroy; @@ -432,11 +437,11 @@ begin ValCap := rsVLEName; if (TitleCaptions.Count > 0) then KeyCap := TitleCaptions[0]; if (TitleCaptions.Count > 1) then ValCap := TitleCaptions[1]; - Columns[0].Title.Caption := KeyCap; - Columns[1].Title.Caption := ValCap; + //Columns[0].Title.Caption := KeyCap; + //Columns[1].Title.Caption := ValCap; //or: - //Cells[0,0] := KeyCap - //Cells[1,0] := ValCap; + Cells[0,0] := KeyCap; + Cells[1,0] := ValCap; end; end; @@ -483,17 +488,19 @@ var I: Integer; begin Result:=''; - if (ARow=0) and (doColumnTitles in DisplayOptions) then begin - if ACol=Strings.Count then - Strings.Insert(I,Line) - else - Strings[I]:=Line; + begin + I:=ARow-FixedRows; + if ACol=0 then + Line:=AValue+'='+Cells[1,ARow] + else + Line:=Cells[0,ARow]+'='+AValue; + if I>=Strings.Count then + Strings.Insert(I,Line) + else + Strings[I]:=Line; + end; end; function TValueListEditor.GetEditText(ACol, ARow: Integer): string;