Topic: pass a procedure on event

hello
whene i wanted to alternate colors of a dbgrid.  there is a message (could not convert variant of type olestr into type boolean)
this is the procedire
procedure Alternate_color( sender:TdbStringGridEx);
var
i,j,maxcol,maxline:integer;

begin

maxline:= sender.rowcount-1;
maxcol:= sender.Columns.Count-1;
for i := 0 to maxcol  do
begin
   for j := 0 to maxline do
   begin
     if (j mod 2)=0 then sender.Cell[i,j].color:=$FFFFFF;
     if (j mod 2)=1 then sender.Cell[i,j].color:=$FFEEEE;
   end;
end;

end;

is there a metjode to do that.
Thank you

Post's attachments

Attachment icon project.rar 295.67 kb, 404 downloads since 2017-11-05 

Re: pass a procedure on event

See attached fix.

Post's attachments

Attachment icon Project Fixed.zip 583.55 kb, 406 downloads since 2017-11-06 

Re: pass a procedure on event

thank you ehwagner for your response but. is there any other solution without adding procedures on-change , on-aftersort ..... on the script file.
i mean i want just make modifications in the alternate-color procedure.
thanks.

Re: pass a procedure on event

Not sure of another solution. The Alternate_Color procedure must know which tablegrid to work on, so something has to pass it on to it. Sorry I can't help you further.

Re: pass a procedure on event

procedure TableGrid_OnChange (Sender: TdbStringGridEx);
var
   i,k,r,c: integer;
begin
     r := Sender.RowCount - 1;
     c := Sender.Columns.Count - 1;
     for i := 0 to r do
          begin
           if i mod 2 = 0 then
              begin
                for k := 0 to c do
                  begin
                    Sender.Cell[k,i].Color := $00FBFBFB;
                  end;
              end;
          end;
end;

Domebil

Re: pass a procedure on event

hello
for ehwagner:  thanks for your try..  the sender parametre should be the component who rased the event. the name of the procedure is pasted in the project explorer in. the onchange fiel.

for domebil: same error message

any other help is welcome. i need this because it is usefull in the case where ther is many dbgrids in the form. i want just to past the name of the procedire int project explorer.

7 (edited by domebil 2017-11-07 07:23:34)

Re: pass a procedure on event

try with this

Post's attachments

Attachment icon Project-mod.rar 295.37 kb, 426 downloads since 2017-11-07 

Domebil

Re: pass a procedure on event

thak you. domebil for your help.
but there is 2 added precedures in the script.
I wanted a universal procedure with just a sender as parametre.
i tried (sender:TObject) but  same error message .
i think that it works in delphi. but i dont know why it do not work in MDV .

thanks a lot. againe

Re: pass a procedure on event

hello
for Administrator. i want to know if it is possible or not
thanks.

Re: pass a procedure on event

hichame wrote:

hello
for Administrator. i want to know if it is possible or not
thanks.

Please download beta version 4.0
http://myvisualdatabase.com/download/myvisualdb40b.exe


Now Sender param in a event is TObject instead String (name of ctrl)


Fixed project:

Post's attachments

Attachment icon project_fixed.zip 7.02 kb, 407 downloads since 2017-11-09 

Dmitry.

Re: pass a procedure on event

Thank you very much.
This is what i wanted: a working TObject parametre.
I will give it a try.
smile

Re: pass a procedure on event

hello
perfect .Now it works like a charme.
i can even copy and past the dbgrid without adding any peoceduee in the script. and it is colored automatically. it can be usufull in other project where there is many components sharing the same procedure ou method. it will work just by copy and past the component in the form.
Geeat work Mr Administrator. and have a nice day to all MDV funs

Post's attachments

Attachment icon project_fixed_2.rar 296.14 kb, 411 downloads since 2017-11-10