Example Delphi
Delphi Examples Collection
Today, Delphi is one of the popular desktop programming tool. There are thousand even million programmer in this world using delphi as their favorit tool. This site try to collect the examples, tips and tricks of Delphi programming. We collect, test them and redistribute the collection of delphi programming for you.
Zoom a Stringgrid
Author: admin | Category: Tips and Tricks, VCL
In this delphi example tutorial we will make an application contain a Stringgrid (TStringgrid) and two Button (TButton). The Stringgrid will be enable for zooming in and zooming out. Firt button will execute a procedure for Zoom In and the other one will execute Zoom Out Procedure. Here the screenshot:

And this is the code:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, StdCtrls; type TForm1 = class(TForm) StringGrid1: TStringGrid; Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure ZoomGrid(AStringgrid:TStringGrid;level:Real); var i:integer; begin for i := 0 to AStringgrid.colcount - 1 do AStringgrid.colwidths[i] := round(AStringgrid.colwidths[i] * level); for i := 0 to AStringgrid.RowCount - 1 do AStringgrid.rowheights[i] := round(AStringgrid.rowheights[i] * level); AStringgrid.Font.Size := round(AStringgrid.rowheights[0] * 0.65); end; procedure TForm1.Button1Click(Sender: TObject); begin ZoomGrid(StringGrid1,1.1); end; procedure TForm1.Button2Click(Sender: TObject); begin ZoomGrid(StringGrid1,0.9); end; end.
Tags: StringGrid, zoom
Post Meta
-
Tips and Tricks, VCL -
Comments Feed -