unit Unit1_Q_21427260;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Edit2: TEdit;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure StringGrid1DrawCell(Sender
private { Private declarations }
gValue: string;
public { Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[1,0] := 'State';
StringGrid1.Cells[1,1] := 'HI';
StringGrid1.Cells[1,2] := 'Hello';
StringGrid1.Cells[1,3] := 'HI';
StringGrid1.Cells[1,4] := 'HI';
StringGrid1.Cells[1,5] := 'Hello';
StringGrid1.Cells[2,0] := 'Singer';
StringGrid1.Cells[2,1] := 'Kylie';
StringGrid1.Cells[2,2] := 'Minogue';
StringGrid1.Cells[2,3] := 'Christina';
StringGrid1.Cells[2,4] := 'Milian';
StringGrid1.Cells[2,5] := 'Beyonce';
gValue := 'HI';
end;
procedure TForm1.Button1Click(Sender
begin
gValue := Edit1.Text;
StringGrid1.Hide;
StringGrid1.Show;
end;
procedure TForm1.Button2Click(Sender
begin
gValue := Edit2.Text;
StringGrid1.Hide;
StringGrid1.Show;
end;
procedure TForm1.StringGrid1DrawCell
begin
with StringGrid1 do
if (Cells[ACol, ARow]=gValue) then
begin
Canvas.Font.Style := [fsBold];
Canvas.TextOut(Rect.Left+2
end;
end;
end.
//........
object Form1: TForm1
Left = 224
Top = 128
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsSingle
Caption = 'Form1'
ClientHeight = 268
ClientWidth = 562
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poDefaultPosOnly
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object StringGrid1: TStringGrid
Left = 20
Top = 56
Width = 464
Height = 192
ColCount = 3
RowCount = 6
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing]
TabOrder = 0
OnDrawCell = StringGrid1DrawCell
end
object Edit1: TEdit
Left = 20
Top = 32
Width = 192
Height = 21
TabOrder = 1
Text = 'HI'
end
object Button1: TButton
Left = 20
Top = 8
Width = 192
Height = 25
Caption = 'Highlight Text'
TabOrder = 2
OnClick = Button1Click
end
object Button2: TButton
Left = 296
Top = 8
Width = 192
Height = 25
Caption = 'Highlight Text'
TabOrder = 3
OnClick = Button2Click
end
object Edit2: TEdit
Left = 296
Top = 32
Width = 192
Height = 21
TabOrder = 4
Text = 'Hello'
end
end
Main Topics
Browse All Topics





by: mokulePosted on 2005-05-17 at 14:36:14ID: 14022743
This should work for You
ll(Sender: TObject; const Rect: TRect; dByName('S tate').AsS tring = 'Hi') and (Column.FieldName = 'State') then ,Rect.Top, Column.Fie ld.AsStrin g);
procedure TFMain.DBGrid1DrawColumnCe
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
d: TDBGrid;
begin
if Sender is TDBGrid then
begin
d := Sender as TDBGrid;
d.Canvas.FillRect(Rect);
if (d.DataSource.DataSet.Fiel
d.Canvas.Font.Style := [fsBold];
else
d.Canvas.Font.Style := [];
d.Canvas.TextOut(Rect.Left
end;
end;