StringGrid....
Olha so pessoal desculpa a minha ignorancia....
mas como faço em uma StringGrid para criar linhas em tempo de execução?
mas como faço em uma StringGrid para criar linhas em tempo de execução?
Lemaf
Curtidas 0
Respostas
Weber
19/10/2005
Unit1.Pas
Unit1.dfm
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure AddGrid(Coluna1, Coluna2, Coluna3: String);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.AddGrid(Coluna1, Coluna2, Coluna3: String);
var
nI: Integer;
begin
if Trim(StringGrid1.Cells[1,1]) = ´´ then
begin
StringGrid1.Cells[1,1] := Coluna1;
StringGrid1.Cells[2,1] := Coluna2;
StringGrid1.Cells[3,1] := Coluna3;
end
else
begin
StringGrid1.RowCount := StringGrid1.RowCount + 1;
StringGrid1.Cells[1,StringGrid1.RowCount -1] := Coluna1;
StringGrid1.Cells[2,StringGrid1.RowCount -1] := Coluna2;
StringGrid1.Cells[3,StringGrid1.RowCount -1] := Coluna3;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
AddGrid(´UM´,´DOIS´,´TRES´);
end;
end.Unit1.dfm
object Form1: TForm1 Left = 273 Top = 185 Width = 696 Height = 480 Caption = ´Form1´ Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = ´MS Sans Serif´ Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object StringGrid1: TStringGrid Left = 88 Top = 72 Width = 457 Height = 217 ColCount = 4 RowCount = 2 TabOrder = 0 end object Button1: TButton Left = 184 Top = 360 Width = 75 Height = 25 Caption = ´Button1´ TabOrder = 1 OnClick = Button1Click end end
GOSTEI 0
Lemaf
19/10/2005
Valeu pela dica........
GOSTEI 0