mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 14:39:13 +02:00
ValEdit: Do not use Columns.Add, it interferes with setting FixedCols := 1 (by adding an extra column in front).
git-svn-id: trunk@39552 -
This commit is contained in:
parent
60f1c2eb6c
commit
2117e8a35f
@ -266,14 +266,18 @@ begin
|
|||||||
FStrings.OnChanging:=@StringsChanging;
|
FStrings.OnChanging:=@StringsChanging;
|
||||||
FTitleCaptions := TStringList.Create;
|
FTitleCaptions := TStringList.Create;
|
||||||
TStringList(FTitleCaptions).OnChange := @TitlesChanged;
|
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
|
with Columns.Add do
|
||||||
Title.Caption := 'Key';
|
Title.Caption := 'Key';
|
||||||
with Columns.Add do begin
|
with Columns.Add do begin
|
||||||
Title.Caption := 'Value';
|
Title.Caption := 'Value';
|
||||||
DropDownRows := 8;
|
DropDownRows := 8;
|
||||||
end;
|
end;
|
||||||
// or: ColCount:=2;
|
}
|
||||||
// inherited RowCount := 2;
|
|
||||||
|
ColCount:=2;
|
||||||
|
inherited RowCount := 2;
|
||||||
FixedCols := 0;
|
FixedCols := 0;
|
||||||
// DefaultColWidth := 150;
|
// DefaultColWidth := 150;
|
||||||
// DefaultRowHeight := 18;
|
// DefaultRowHeight := 18;
|
||||||
@ -284,6 +288,7 @@ begin
|
|||||||
FDisplayOptions := [doColumnTitles, doAutoColResize, doKeyColFixed];
|
FDisplayOptions := [doColumnTitles, doAutoColResize, doKeyColFixed];
|
||||||
Col := 1;
|
Col := 1;
|
||||||
FDropDownRows := 8;
|
FDropDownRows := 8;
|
||||||
|
ShowColumnTitles;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TValueListEditor.Destroy;
|
destructor TValueListEditor.Destroy;
|
||||||
@ -432,11 +437,11 @@ begin
|
|||||||
ValCap := rsVLEName;
|
ValCap := rsVLEName;
|
||||||
if (TitleCaptions.Count > 0) then KeyCap := TitleCaptions[0];
|
if (TitleCaptions.Count > 0) then KeyCap := TitleCaptions[0];
|
||||||
if (TitleCaptions.Count > 1) then ValCap := TitleCaptions[1];
|
if (TitleCaptions.Count > 1) then ValCap := TitleCaptions[1];
|
||||||
Columns[0].Title.Caption := KeyCap;
|
//Columns[0].Title.Caption := KeyCap;
|
||||||
Columns[1].Title.Caption := ValCap;
|
//Columns[1].Title.Caption := ValCap;
|
||||||
//or:
|
//or:
|
||||||
//Cells[0,0] := KeyCap
|
Cells[0,0] := KeyCap;
|
||||||
//Cells[1,0] := ValCap;
|
Cells[1,0] := ValCap;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -483,17 +488,19 @@ var
|
|||||||
I: Integer;
|
I: Integer;
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
if (ARow=0) and (doColumnTitles in DisplayOptions) then begin
|
if (ARow=0) and (doColumnTitles in DisplayOptions) then
|
||||||
if ACol<FTitleCaptions.Count then
|
begin
|
||||||
Result:=FTitleCaptions[ACol];
|
Result := Inherited GetCells(ACol, ARow);
|
||||||
exit;
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
I:=ARow-FixedRows;
|
||||||
|
if Strings.Count<=I then exit;
|
||||||
|
if ACol=0 then
|
||||||
|
Result:=Strings.Names[I]
|
||||||
|
else if ACol=1 then
|
||||||
|
Result:=Strings.ValueFromIndex[I];
|
||||||
end;
|
end;
|
||||||
I:=ARow-FixedRows;
|
|
||||||
if Strings.Count<=I then exit;
|
|
||||||
if ACol=0 then
|
|
||||||
Result:=Strings.Names[I]
|
|
||||||
else if ACol=1 then
|
|
||||||
Result:=Strings.ValueFromIndex[I];
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TValueListEditor.SetCells(ACol, ARow: Integer; const AValue: string);
|
procedure TValueListEditor.SetCells(ACol, ARow: Integer; const AValue: string);
|
||||||
@ -501,15 +508,22 @@ var
|
|||||||
I: Integer;
|
I: Integer;
|
||||||
Line: string;
|
Line: string;
|
||||||
begin
|
begin
|
||||||
I:=ARow-FixedRows;
|
if (ARow = 0) and (doColumnTitles in DisplayOptions) then
|
||||||
if ACol=0 then
|
begin
|
||||||
Line:=AValue+'='+Cells[1,ARow]
|
Inherited SetCells(ACol, ARow, AValue);
|
||||||
|
end
|
||||||
else
|
else
|
||||||
Line:=Cells[0,ARow]+'='+AValue;
|
begin
|
||||||
if I>=Strings.Count then
|
I:=ARow-FixedRows;
|
||||||
Strings.Insert(I,Line)
|
if ACol=0 then
|
||||||
else
|
Line:=AValue+'='+Cells[1,ARow]
|
||||||
Strings[I]:=Line;
|
else
|
||||||
|
Line:=Cells[0,ARow]+'='+AValue;
|
||||||
|
if I>=Strings.Count then
|
||||||
|
Strings.Insert(I,Line)
|
||||||
|
else
|
||||||
|
Strings[I]:=Line;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TValueListEditor.GetEditText(ACol, ARow: Integer): string;
|
function TValueListEditor.GetEditText(ACol, ARow: Integer): string;
|
||||||
|
Loading…
Reference in New Issue
Block a user