İyinet'e Hoşgeldiniz!

Türkiye'nin En Eski Webmaster Forum'una Hemen Kayıt Olun!

Kayıt Ol!

string grid

A

Anonymous

Misafir
string grid'de herhangibir colonun yada row un text'inin rengini nasıl değiştiriyoruz?mesela 1.colonun 1.rowundaki yazının rengini değiştirmek istiyorum bunu nasıl yapabilirim yardımcı olursanız sevinirim.
stringgrid1.canvas.brush.color:=clred;
komutundan baska bi komut yokmu cunki bu yapmıyor:)
 
A

Anonymous

Misafir
Merhaba

Aşağıdaki koda bir bakın (Usenet'de bir delphi grubundan buldum, denedim çalışıyor. Bir form hazırlayıp içine bir string grid koyup stringgrid'in ondrawcwell hadisesine atamanız lazım StringGrid1DrawCell isimli prosedürü) :

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;

type
TForm1 = class(TForm)
Button1: TButton;
StringGrid1: TStringGrid;
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState);
var
OldColor : TColor;
OldBrush : TBrush;
begin with StringGrid1.Canvas do begin
OldColor := Font.Color;
OldBrush := Brush;

{paint fridays}
if StringGrid1.Cells[ACol,1] = 'Fr' then begin
Brush.Color := $02aaaaaa; {light gray}
FillRect(Rect);
Font.Color := clWhite;
TextOut(Rect.Left+2,Rect.Top+2,StringGrid1.Cells[ACol,ARow]);
end;

{paint each alternating month}
if (ARow = 0) and (ACol > 0) then begin
if (Odd(StrToIntDef(StringGrid1.Cells[ACol,31],0))) then
Brush.Color := clBlue
else
Brush.Color := clFuchsia;

FillRect(Rect);
Font.Color := clWhite;
TextOut(Rect.Left+2,Rect.Top+2,StringGrid1.Cells[ACol,ARow]);
end;

{paint days of the week}
if (ARow = 1) and (ACol > 0) then begin
if StringGrid1.Cells[ACol,1] = 'Fr' then
Brush.Color := clTeal else
Brush.Color := clAqua;
FillRect(Rect);
if StringGrid1.Cells[ACol,1] = 'Fr' then
Font.Color := clWhite else
Font.Color := clBlack;

TextOut(Rect.Left+2,Rect.Top+2,StringGrid1.Cells[ACol,ARow]);
end;


Font.Color := OldColor;
Brush := OldBrush;

end;

end;


end.
 

Türkiye’nin ilk webmaster forum sitesi iyinet.com'da forum üyeleri tarafından yapılan tüm paylaşımlardan; Türk Ceza Kanunu’nun 20. Maddesinin, 5651 Sayılı Kanununun 4. maddesinin 2. fıkrasına göre, paylaşım yapan üyeler sorumludur.

Backlink ve Tanıtım Yazısı için iletişime geçmek için Skype Adresimiz: .cid.1580508955483fe5

Üst