Hallo, my first post here and i want to salute all the members.
I come with a problem:
I have a stringgrid and i need to change cells color when i modify the data inside. How can i do that?
Thanks!
procedure Tform1.CMFocusChanged(var Message: TCMFocusChanged);
var
i:integer;
grenk,crenk : tcolor;
BEGIN
grenk := clwhite;
crenk := clred; // Prefer
if (message.sender is TStringGrid)
then
begin
for i:=0 to componentcount-1 do
begin
if components[i] is TStringGrid then
TStringGrid(components[i]).color:= grenk;
end;
end;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,StdCtrls, Mask, DBCtrls, Grids, DBGrids,extctrls, dbcgrids,
CheckLst, dblookup ;
type
TForm1 = class(TForm)
Edit1: TEdit;
Memo1: TMemo;
ListBox1: TListBox;
ComboBox1: TComboBox;
DBEdit1: TDBEdit;
DBCheckBox1: TDBCheckBox;
DBComboBox1: TDBComboBox;
DBGrid1: TDBGrid;
DBMemo1: TDBMemo;
DBListBox1: TDBListBox;
MaskEdit1: TMaskEdit;
CheckListBox1: TCheckListBox;
Timer1: TTimer;
StringGrid1: TStringGrid;
private
{ Private declarations }
public
{ Public declarations }
procedure CMfocuschanged(var message: TCMfocuschanged); message CM_Focuschanged;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure Tform1.CMFocusChanged(var Message: TCMFocusChanged);
var
i:integer;
grenk,crenk : tcolor;
BEGIN
grenk := clwhite;
crenk := clred;
if (message.sender is tedit) or
(message.sender is tcombobox) or
(message.sender is tlistbox) or
(message.sender is tcheckbox) or
(message.sender is tradiobutton) or
(message.sender is tdbedit)or
(message.sender is tdbcombobox) or
(message.sender is tdblistbox) or
(message.sender is tdbcheckbox) or
(message.sender is TMemo) or
(message.sender is TDBMemo) or
(message.sender is TDBGrid) or
(message.sender is TMaskEdit) or
(message.sender is TStringGrid) or
(message.sender is TDrawGrid) or
(message.sender is TCheckListBox) or
(message.sender is TDBRichEdit) or
(message.sender is TDBLookupListBox) or
(message.sender is TDBLookupComboBox)
then
begin
for i:=0 to componentcount-1 do
begin
if components[i] is tedit then
tedit(components[ i ]).color:= grenk;
if components[i] is tcombobox then
tcombobox(components[i]).color:= grenk;
if components[i] is tlistbox then
tlistbox(components[i]).color:= grenk;
if components[i] is tcheckbox then
tcheckbox(components[i]).color := grenk;
if components[i] is tradiobutton then
tradiobutton(components[i]).color:= grenk;
if components[i] is tdbedit then
tdbedit(components[i]).color:= grenk;
if components[i] is tdbcombobox then
tdbcombobox(components[i]).color:= grenk;
if components[i] is tdblistbox then
tdblistbox(components[i]).color:= grenk;
if components[i] is tdbcheckbox then
tdbcheckbox(components[i]).color:= grenk;
if components[i] is TMemo then
TMemo(components[i]).color:= grenk;
if components[i] is TDBMemo then
TDBMemo(components[i]).color:= grenk;
if components[i] is TDBGrid then
TDBGrid(components[i]).color:= grenk;
if components[i] is TMaskEdit then
TMaskEdit(components[i]).color:= grenk;
if components[i] is TStringGrid then
TStringGrid(components[i]).color:= grenk;
if components[i] is TDrawGrid then
TDrawGrid(components[i]).color:= grenk;
if components[i] is TCheckListBox then
TCheckListBox(components[i]).color:= grenk;
if components[i] is TDBRichEdit then
TDBRichEdit(components[i]).color:= grenk;
if components[i] is TDBLookupListBox then
TDBLookupListBox(components[i]).color:= grenk;
if components[i] is TDBLookupComboBox then
TDBLookupComboBox(components[i]).color:= grenk;
end ;
tedit(message.sender).color:=crenk;
end
end;
Users browsing this forum: No registered users and 1 guest