Pintando StringGrid
Colegas onde estou errando nesse código
procedure TForm1.GridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
CarregarGrid;
if (ACol = Coluna) and (ARow = Linha) then
Grid.Canvas.Brush.color := clBlue;
Grid.canvas.fillRect(Rect);
Grid.Canvas.TextRect(Rect, Rect.Left,
Rect.Top,Grid.Cells[Coluna, Linha]);
end;
-----------------------------------------------------------
CarregarGrid é assim:
with qryAuxiliar do
begin
Close;
SQL.Clear;
SQL.Add(´Select de_Coluna, de_Linha, de_Cor From Tab_Grid´);
Open;
end;
if qryAuxiliar.RecordCount > 0 then
begin
Coluna:= qryAuxiliar.FieldByName(´de_Coluna´).AsInteger;
Linha:= qryAuxiliar.FieldByName(´de_Linha´).AsInteger;
end;
----------------------------------------------------------------------------------
Se eu fizer assim:
procedure TForm1.GridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
Coluna:= 1;
Linha:= 2;
if (ACol = Coluna) and (ARow = Linha) then
Grid.Canvas.Brush.color := clBlue;
Grid.canvas.fillRect(Rect);
Grid.Canvas.TextRect(Rect, Rect.Left,
Rect.Top,Grid.Cells[Coluna, Linha]);
end;
Funciona onde estou errando?, pois quero pegar os valores de Coluna e Linha que vem de uma tabela no Access.
procedure TForm1.GridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
CarregarGrid;
if (ACol = Coluna) and (ARow = Linha) then
Grid.Canvas.Brush.color := clBlue;
Grid.canvas.fillRect(Rect);
Grid.Canvas.TextRect(Rect, Rect.Left,
Rect.Top,Grid.Cells[Coluna, Linha]);
end;
-----------------------------------------------------------
CarregarGrid é assim:
with qryAuxiliar do
begin
Close;
SQL.Clear;
SQL.Add(´Select de_Coluna, de_Linha, de_Cor From Tab_Grid´);
Open;
end;
if qryAuxiliar.RecordCount > 0 then
begin
Coluna:= qryAuxiliar.FieldByName(´de_Coluna´).AsInteger;
Linha:= qryAuxiliar.FieldByName(´de_Linha´).AsInteger;
end;
----------------------------------------------------------------------------------
Se eu fizer assim:
procedure TForm1.GridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
Coluna:= 1;
Linha:= 2;
if (ACol = Coluna) and (ARow = Linha) then
Grid.Canvas.Brush.color := clBlue;
Grid.canvas.fillRect(Rect);
Grid.Canvas.TextRect(Rect, Rect.Left,
Rect.Top,Grid.Cells[Coluna, Linha]);
end;
Funciona onde estou errando?, pois quero pegar os valores de Coluna e Linha que vem de uma tabela no Access.
Mssilva
Curtidas 0