LCL, fix dbgrid exception while setting up automatic columns (regresion introduced in r24057 #22775e7a58), issue #16031

git-svn-id: trunk@24072 -
This commit is contained in:
jesus 2010-03-17 20:42:28 +00:00
parent 32b73ebd75
commit 27045012a8

View File

@ -5003,6 +5003,9 @@ procedure TCustomGrid.doOPMoveColRow(IsColumn: Boolean; FromIndex, ToIndex: Inte
var
ColRow: Integer;
begin
if FromIndex=ToIndex then
exit;
CheckIndex(IsColumn, FromIndex);
CheckIndex(IsColumn, ToIndex);
@ -6767,12 +6770,14 @@ end;
function TCustomGrid.GridColumnFromColumnIndex(ColumnIndex: Integer): Integer;
begin
{$ifdef NewCols}
result := ColumnIndex;
result := ColumnIndex + FirstGridColumn;
if Result>ColCount-1 then
Result := -1;
{$else}
result := Columns.VisibleIndex(ColumnIndex);
{$endif}
if result>=0 then
result := result + FixedCols;
{$endif}
end;
procedure TCustomGrid.GridMouseWheel(shift: TShiftState; Delta: Integer);
@ -9838,13 +9843,16 @@ var
begin
AGrid := Grid;
if (not FSettingIndex) and (AGrid<>nil) then begin
FSettingIndex := true;
CurCol := Grid.GridColumnFromColumnIndex(Index);
DstCol := Grid.GridColumnFromColumnIndex(Value);
Grid.DoOPMoveColRow(true, CurCol, DstCol);
FSettingIndex := false;
end else
inherited SetIndex(Value);
if (CurCol>=0) and (DstCol>=0) then begin
FSettingIndex := true;
Grid.DoOPMoveColRow(true, CurCol, DstCol);
FSettingIndex := false;
exit;
end;
end;
inherited SetIndex(Value);
end;
constructor TGridColumn.Create(ACollection: TCollection);