Description : contient l'objet LRJ_TStringGrid qui dérive de TStringGrid et contient
9 méthodes supplémentaires. Une méthode sert à dimensionner les colonnes en fonction de
la taille maximum prise par le texte des cellules, 3 méthodes servent à vider des
cellules (toutes, selon une ligne et une colonne de départ, les cellules non fixées),
une méthode pour supprimer une ligne et décaler les lignes restantes pour
occuper la place vidée, une pour mettre en sur-brillance une ligne, une pour mettre en sur-brillance
toutes les lignes, une pour donner l'index de
la ligne sélectionnée et une dernière pour donner le nombre de lignes sélectionnées.
{--------------------------------------------------------------}
{--------------------------------------------------------------}
{-------------------- LRJ_TStringGrid ------------------------------------------}
{--------------------------------------------------------------}
{--------------------------------------------------------------}
procedure LRJ_TStringGrid.SelectOneRow(const ARowIndex: integer);
var
zSelect:TGridRect;
begin
zSelect.Top := ARowIndex;
zSelect.Left := FixedCols;
zSelect.Bottom := ARowIndex;
zSelect.Right := ColCount-1;
Selection := zSelect;
end;
{--------------------------------------------------------------}
procedure LRJ_TStringGrid.DeleteOneRow(const ARowIndex: integer);
var
i, j : integer;
begin
if (ARowIndex >= 0) and (ARowIndex < RowCount) then
begin
for i:= ARowIndex to RowCount-2 do
for j:=0 to ColCount-1 do
begin
Cells[j,i] := Cells[j,i+1];
end;
for j:=0 to ColCount-1 do
begin
Cells[j,RowCount-1] := '';
end;
i := RowCount - 1;
RowCount := i;
end;
end;
{--------------------------------------------------------------}
function LRJ_TStringGrid.GetCountRowSelect: integer;
begin
result := 0;
if Selection.top > 0 then
begin
result := (Selection.Bottom - Selection.top) + 1;
if result < 0 then result := 0;
end;
end;
{--------------------------------------------------------------}
procedure LRJ_TStringGrid.SelectAll;
var
zSelect:TGridRect;
begin
zSelect.Top := FixedRows;
zSelect.Left := FixedCols;
zSelect.Bottom := RowCount-1;
zSelect.Right := ColCount-1;
Selection := zSelect;
end;
{--------------------------------------------------------------}
procedure LRJ_TStringGrid.ClearCellsNotFixed;
var
i, j: integer;
begin
for i:=FixedRows to RowCount-1 do
for j:=FixedCols to ColCount-1 do
Cells[j ,i] := '';
end;
{--------------------------------------------------------------}
procedure LRJ_TStringGrid.ClearCells(const BeginCol: integer; const BeginRow: integer);
var
i, j: integer;
begin
for i:=BeginRow to RowCount-1 do
for j:=BeginCol to ColCount-1 do
Cells[j ,i] := '';
end;
{--------------------------------------------------------------}
procedure LRJ_TStringGrid.ClearCells;
var
i, j: integer;
begin
for i:=0 to RowCount-1 do
for j:=0 to ColCount-1 do
Cells[j ,i] := '';
end;
{--------------------------------------------------------------}
function LRJ_TStringGrid.GetRowIndexSelect: integer;
begin
result := Selection.top;
end;
{--------------------------------------------------------------}
procedure LRJ_TStringGrid.ResizeCells(const AFreeSpacing: integer = 0);
var
i, j : integer;
zTabMax: array of integer;
zTempLength: integer;
begin
SetLength(zTabMax,ColCount);
for i:=0 to RowCount-1 do
for j:=0 to ColCount-1 do
begin
zTempLength := Canvas.TextWidth(Cells[j ,i]) + AFreeSpacing;
if zTempLength > zTabMax[j] then zTabMax[j] := zTempLength;
end;
for j:=0 to ColCount-1 do
ColWidths[j] := zTabMax[j];
zTabMax := nil;
end;
{--------------------------------------------------------------}
{--------------------------------------------------------------}
{-------------------- FIN ------------------------------------------}
{--------------------------------------------------------------}
{--------------------------------------------------------------}
end.