.


:




:

































 

 

 

 


procedure TForm1.ReCalculation;

15-16

.

:

1. Delphi;

2. Delphi, .

3. , , , .

 

- 4 .

.

 

: N (1≤N≤10), : , , . , , , . (. . 1).

 

. 1.

  1. Windows , . .
  2. Delphi 7.
  3. , . Save (Ctrl+S). .
  4. Object Inspector Form1:
Caption  
Font\Size    
Position poScreenCenter  
BorderStyle bsNone  
Height    
Width    
  1. 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  
  1. .
  2. Chart\Series . .
  3. Series\Marks Style Percent.
  4. Chart\Titles .
  5. , , (2 3 . , :
..
         
         
       
n        

, Chart1 . Chart1 ObjectTreeView Delete . .. 5g, 6 9 .

  1. .
  2. 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;

 

 

  1. 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;

 

  1. , (. . ! . ! . 2). , . , . , , , , , , , , ..

 

    1. Button1lick onClick, TButton1 ():

 

procedure TForm1.Button1Click(Sender: TObject);

begin

Close;

end;

 

    1. 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; { }

 

    1. 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; { }

    1. EditStringGrid1KeyUp onKeyUp, StringGrid1 ( ) :

 

procedure TForm1.StringGrid1KeyUp(

Sender: TObject; var Key: Word; Shift: TShiftState);

begin { }

ReCalculation;

end; { }

 

  1. (. .. ! . ! . 2) begin FormCreate, Edit1Change StringGrid1KeyUp.
  2. . Run (F9).
  3. . : , .
  4. ( ) FormCreate, Edit1Change StringGrid1KeyUp, , 4, Trace into (F7) Delphi. FormCreate, Edit1Change StringGrid1KeyUp StringGrid1KeyUp ( end;), . Run (F9). StringGrid1KeyUp ( ) StringGrid1KeyUp ( ). , , .
  5. . 4 , Step over (F8) Delphi. Edit1Change.
  6. ! . ! . StringGrid1KeyUp ReCalculation 2-, 3- 4- .
  7. begin.
  8. . Save (Ctrl+S).
  9. Delphi File\Exit.

 

:

    1. ;
    2. ;
    3. , ;


<== | ==>
145. ? |
:


: 2015-11-23; !; : 598 |


:

:

, .
==> ...

1536 - | 1306 -


© 2015-2024 lektsii.org - -

: 0.035 .