Ciao , riesci mica a postare il codice ? Che versione hai di lazarus ?
Comincio dalla 2a domanda: Lazarus 2.2.0
il codice prepara solo i titoli delle colonne 2 e 3, perché la col.1 è stata impostata in fase di disegno anche nel titolo:
procedure FaiGridMovv(); // costruisce la griglia dei movimenti corrispondenti al contenuto della CBstriX.Text
var
swOpenErro: Boolean = False;
i, iRgGrid: Integer;
coVoCorr, nuProEdt, sql, voceCorr: String;
begin
case Form6.tipoRicerca of
'0', '1', '2', '3', '4', '5', '6':
begin
Form6.Panel5.Width:= Form6.Width - 170;
Form6.Panel5.Height:= Form1.Height - 130;
Form6.GridMovvComune.Width:= Form6.Panel5.Width - 4;
Form6.GridMovvComune.Height:= Form6.Panel5.Height - 8;
end;
end;
case Form6.tipoRicerca of
'0': // Ricerca per: Descrizione(0)
begin
. . .
end;
'1', '2', '6': // Ricerca per: Voci contabil1 di Cassa(1, 2,), Cmponente familiare(6)
begin
end;
'3', '4', '5':
begin
Form6.GridMovvComune.Columns[1].Title.Caption:= 'D A R E'; // col.2
Form6.GridMovvComune.Columns[2].Title.Caption:= 'A V E R E'; // col.3
Form6.GridMovvComune.Columns[3].Title.Caption:= 'DESCRIZIONE';
Form6.GridMovvComune.Columns[4].MaxSize:= 500;
Form6.GridMovvComune.Columns[4].MinSize:= 350;
Form6.GridMovvComune.Columns[4].Width:= 500;
Form6.GridMovvComune.Columns[4].Alignment:= taLeftJustify;
Form6.GridMovvComune.Columns[4].Title.Caption:= 'VOCE DI CONTROPARTITA';
Form6.GridMovvComune.Columns[5].MaxSize:= 120;
Form6.GridMovvComune.Columns[5].MinSize:= 120;
Form6.GridMovvComune.Columns[5].Width:= 120;
Form6.GridMovvComune.Columns[5].Alignment:= taCenter;
Form6.GridMovvComune.Columns[5].Title.Caption:= 'CODICE VOCE';
Form6.GridMovvComune.Columns[6].MaxSize:= 500;
Form6.GridMovvComune.Columns[6].MinSize:= 350;
Form6.GridMovvComune.Columns[6].Width:= 500;
Form6.GridMovvComune.Columns[6].Alignment:= taLeftJustify;
Form6.GridMovvComune.Columns[6].Title.Caption:= 'VOCE DI CASSA';
Form6.GridMovvComune.Columns[7].MaxSize:= 120;
Form6.GridMovvComune.Columns[7].MinSize:= 120;
Form6.GridMovvComune.Columns[7].Width:= 120;
Form6.GridMovvComune.Columns[7].Alignment:= taCenter;
Form6.GridMovvComune.Columns[7].Title.Caption:= 'CODICE VOCE';
Form6.GridMovvComune.Columns[7].Visible:= True;
end;
end;
Ho inserito solamente la porzione di codice che sto provando (tipoRicerca = 4).
Poi dentro l'evento DrawCell imposto il colore di sfondo per le celle dei totali e del titolo (quest'ultimo, perché ho trovato cambiato anche quello col colore di sfondo delle celle coi totali (**?**).
però, anche prima di detta modifica il testo non era visualizzato:
procedure TForm6.GridMovvComuneDrawCell(Sender: TObject; aCol, aRow: Integer;
aRect: TRect; aState: TGridDrawState);
type
Tsfondo = TColor;
const
sfondoBlu: Tsfondo = clBlue;
sfondoVerde: Tsfondo = $0080801C; // Verde scuro
sfondo: Tsfondo = clWindow;
var
lun: Integer;
ixRg: Integer = 0;
cellaSel: String;
allin : TTextStyle; // tipo di allineamento
begin
WriteLn('TForm6.GridMovvComuneDrawCell');
case aCol of
1, 2, 3:
begin
WriteLn('cella corrente = col.' + IntToStr(aCol) + ' - rg.' + IntToStr(aRow));
if (GridMovvComune.Cells[1, aRow] = 'TOT.Sottoconto') then
begin
sfondo:= sfondoVerde;
ixRg:= aRow;
end;
if (GridMovvComune.Cells[1, aRow] = 'TOTALI Conto') or (GridMovvComune.Cells[1, aRow] = 'T O T A L I') then
begin
sfondo:= sfondoBlu;
ixRg:= aRow
end;
if (aRow = 0) then
begin
sfondo:= clBtnFace; // Impostazione del colore di sfondo delle celle di testata delle colonne 1, 2, 3 (per tutte le altre il colore impostato in fase di disegno funziona)
ixRg:= aRow
end;
cellaSel:= GridMovvComune.Cells[aCol, aRow]; // punta alla casella selezionata
if (ixRg = aRow) then
begin
GridMovvComune.Canvas.Brush.Color := sfondo;
GridMovvComune.Canvas.FillRect(aRect);
GridMovvComune.Canvas.Font.Style:= [fsBold];
GridMovvComune.Canvas.Font.Color:= clYellow; // colora il testo
allin.Alignment:= taRightJustify;
GridMovvComune.Canvas.TextRect(aRect, aRect.Right - lun , aRect.Top, CellaSel, allin);
if (aCol = 1) then
begin
GridMovvComune.Canvas.Font.Height:= 14;
end
else begin
GridMovvComune.Canvas.Font.Height:= 11;
end;
end;
ixRg:= 0;
end;
end;
end;