15-16
.
:
1. Delphi;
2. Delphi, .
3. , , , .
- 4 .
.
: N (1≤N≤10), : , , . , , , . (. . 1).
. 1.
- Windows , . .
- Delphi 7.
- , . Save (Ctrl+S). .
- Object Inspector Form1:
Caption | ||
Font\Size | ||
Position | poScreenCenter | |
BorderStyle | bsNone | |
Height | ||
Width |
- Form1 (. . 1) .
a. Edit1 TEdit :
Width | ||
Hint | ||
ShowHint | True |
b. UpDown1 TupDown :
Associate | Edit1 | |
Max | ||
Min | ||
Orientation | udVertical |
c. Label1 TLabel :
Caption | : |
d. GroupBox1 TgroupBox :
Caption | ||
Ctl3D | False | |
Height | ||
Hint | ||
Left | ||
ShowHint | True | |
Top | ||
Width |
e. StringGrid1 TStringGrid ( StringGrid (Grids) Additional) :
Align | alClient | |
ColCount | ||
FixedCols | ||
FixedRows | ||
Options\goEditing | True | |
RowCount | ||
ScrollBars | ssNone | |
Options\goColSizing | True |
f. Button1 TButton :
|
|
Caption | ||
Enabled | True | |
Hint | ||
ShowHint | True |
g. Chart1 TChart ( Chart (Chart) Additional) :
BevelInner | bvNone | |
BevelOuter | bvNone | |
Title | ||
AxisVisible | False |
- .
- Chart\Series . .
- Series\Marks Style Percent.
- Chart\Titles .
- , , (2 3 . , :
.. | ||||
n |
, Chart1 . Chart1 ObjectTreeView Delete . .. 5g, 6 9 .
- .
- TForm1 ( Unit1) ReCalculation:
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
UpDown1: TUpDown;
GroupBox1: TGroupBox;
StringGrid1: TStringGrid;
Button1: TButton;
Chart1: TChart;
Series1: TPieSeries;
private
{ Private declarations }
Procedure ReCalculation;
public
{ Public declarations }
end;
- implementation Unit1 ReCalculation:
implementation
{$R *.dfm}
procedure TForm1.ReCalculation;
Var
I:Integer;
Begin
Chart1.Series[0].Clear;
For i:=1 to StringGrid1.ColCount-1 Do
Begin
Try
StringGrid1.Cells[i,4]:=
FloatToStr(
Round(
100*StrToFloat(StringGrid1.Cells[i,3])*
StrToFloat(StringGrid1.Cells[i,2]))/100);
Chart1.Series[0].Add(
StrToFloat(StringGrid1.Cells[I,4]),
StringGrid1.Cells[i,1]);
Except
StringGrid1.Cells[i,4]:='?';
Beep;
End;
End;
End;
- , (. . ! . ! . 2). , . , . , , , , , , , , ..
|
|
- Button1lick onClick, TButton1 ():
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
- FormCreate onCreate, Form1 ( ) :
procedure TForm1.FormCreate(Sender: TObject);
begin { }
StringGrid1.Cells[0,0]:=' ..';
StringGrid1.Cells[0,1]:='';
StringGrid1.Cells[0,2]:='';
StringGrid1.Cells[0,3]:='';
StringGrid1.Cells[0,4]:='';
StringGrid1.Cells[1,0]:='1';
StringGrid1.Cells[1,2]:='0,0';
StringGrid1.Cells[1,3]:='0,0';
ReCalculation;
end; { }
- Edit1Change onChange, Edit1 ( ) :
procedure TForm1.Edit1Change(Sender: TObject);
begin { }
StringGrid1.ColCount:=StrToInt(Edit1.Text)+1;
StringGrid1.Cells[StrToInt(Edit1.Text),0]:= Edit1.Text;
If StringGrid1.Cells[StrToInt(Edit1.Text),2]=''
then StringGrid1.Cells[StrToInt(Edit1.Text),2]:='0,0';
If StringGrid1.Cells[StrToInt(Edit1.Text),3]=''
then StringGrid1.Cells[StrToInt(Edit1.Text),3]:='0,0';
ReCalculation;
end; { }
- EditStringGrid1KeyUp onKeyUp, StringGrid1 ( ) :
procedure TForm1.StringGrid1KeyUp(
Sender: TObject; var Key: Word; Shift: TShiftState);
begin { }
ReCalculation;
end; { }
- (. .. ! . ! . 2) begin FormCreate, Edit1Change StringGrid1KeyUp.
- . Run (F9).
- . : , .
- ( ) FormCreate, Edit1Change StringGrid1KeyUp, , 4, Trace into (F7) Delphi. FormCreate, Edit1Change StringGrid1KeyUp StringGrid1KeyUp ( end;), . Run (F9). StringGrid1KeyUp ( ) StringGrid1KeyUp ( ). , , .
- . 4 , Step over (F8) Delphi. Edit1Change.
- ! . ! . StringGrid1KeyUp ReCalculation 2-, 3- 4- .
- begin.
- . Save (Ctrl+S).
- Delphi File\Exit.
|
|
:
- ;
- ;
- , ;