Показать сообщение отдельно
  #1  
Старый 08.04.2013, 19:01
inosel inosel вне форума
Прохожий
 
Регистрация: 07.04.2013
Сообщения: 1
Версия Delphi: Delphi 7
Репутация: 10
По умолчанию Создать график из значений StringGrid

Есть рабочая программа. Данные в StringGrid вводятся с Edit.
Подскажите, как вывести значения из Edit5 в строку, под первой и можно ли построить график с вещественными числами и как это сделать?

Код:
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, TeEngine, Series, ExtCtrls, TeeProcs, Chart;
 
type
  TForm1 = class(TForm)
    StringGrid: TStringGrid;
    Button1: TButton;
    Chart1: TChart;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Button2: TButton;
    Series2: TBarSeries;
    Series1: TLineSeries;
    Edit5: TEdit;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
var
  Col, Row : Integer;
  X, Y : Double;
  Sg : TStringGrid;
  S : String;
begin
  Sg := StringGrid;
  Series1.Clear;
  Row := Sg.FixedRows;
  for Col := Sg.FixedCols to Sg.ColCount - 1 do begin
    X := StrToFloatDef( Sg.Cells[Col, Row], 0 );
    Y := StrToFloatDef( Sg.Cells[Col, Row], 0 );
    //Легенда
       Series1.AddXY(X, Y, S);
  end;
end;
 
procedure TForm1.Button2Click(Sender: TObject);
var
  i,str, k: integer;
begin
  str:=1;
  StringGrid.RowCount:=StringGrid.RowCount+1;
  StringGrid.Col:=1;
  StringGrid.SetFocus;
  StringGrid.Cells[1,str]:=Edit1.Text;
  StringGrid.Cells[2,str]:=Edit2.Text;
  StringGrid.Cells[3,str]:=Edit3.Text;
  StringGrid.Cells[4,str]:=Edit4.Text;
      for i:=2 to   5 do
    begin
      k:=0;
      StringGrid.ColCount:=StringGrid.ColCount+2;
      k:=k+1;
    StringGrid.Cells[k,i]:=Edit5.Text;
         end;
  end;
 
end.
Ответить с цитированием