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.
Change TDBGrid Row Height
Author: admin | Category: Database, Tips and Tricks, VCL
Examples that we will make here is about the TDBGrid Row height settings. If we want to change our DBGrid display by adding or reducing the high DBGrid row, can be done in the following ways:
- To make this example we need a component TDBGrid, TButton and TEdit on Form1. Button1 will be used to trigger changes to high DBGrid with Edit1 lines as input.
- Please set DBGrid to connect with the tables from the database. In the example I gave I use the table from the database DEMODATA Department.
- Use this following code.
Here is the source code. If you want to download the source code examples, please click Here

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids, DBGrids, DB, ADODB, ExtCtrls; type TForm1 = class(TForm) DBGrid1: TDBGrid; DataSource1: TDataSource; ADOConnection1: TADOConnection; ADODataSet1: TADODataSet; Panel1: TPanel; Button1: TButton; Edit1: TEdit; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; TMyDBGrid = class(TDBGrid) public property DefaultRowHeight; end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin DBGrid1.DataSource.DataSet.DisableControls; TStringGrid(DBGrid1).DefaultRowHeight := StrToIntDef(Edit1.Text,10); DBGrid1.DataSource.DataSet.EnableControls; end; procedure TForm1.FormCreate(Sender: TObject); begin DbGrid1.Canvas.Font.Size := 13; TMyDBGrid(DBGrid1).DefaultRowHeight := DBGrid1.Canvas.TextHeight('MMMMM') + 4; end; end.
Post Meta
-
Database, Tips and Tricks, VCL -
Comments Feed -