adding properties of stringgrid

edited 2:18AM in FastScript
Ls.

Read the docs/*.pas but can't (my lack of knowledge, I guess) figure out how to add the stringgrid property cells to be known to a script. Came as far as:

with fsscript1.AddClass(TAdvStringGrid,'TGrid') do
AddProperty('Cells', 'String'...

... anyone can help me out?

Regards,
H

Comments

  • edited 2:18AM
    You should add TGrid first (it's not added in the FS by default).
    Also you should use fsGlobalUnit to add classes.

    with fsGlobalUnit do
    begin
    AddClass(TCustomGrid, 'TCustomControl');
    AddClass(TDrawGrid, 'TCustomGrid');
    with AddClass(TStringGrid, 'TDrawGrid') do
    begin
    AddIndexProperty('Cells', 'Integer,Integer', 'String', CallMethod);
    end;
    end;

    Example of CallMethod you can found in the fs_i*rtti.pas files. Also read the manual how to add a property, index property, method.
  • edited 2:18AM
    Ok, read the examples again, added a basegrid and advstringgrid class and came as far as the callmethod:

    ...
    AddClass(TCustomGrid, 'TCustomControl');
    AddClass(TDrawGrid, 'TCustomGrid');
    AddClass(TStringGrid, 'TDrawGrid');
    AddClass(TBaseGrid, 'TStringGrid');
    with AddClass(TAdvStringGrid, 'TBaseGrid') do begin
    AddIndexProperty('Cells', 'Integer,Integer', 'String', CallMethod);
    end;
    ...

    function TfrmMain.CallMethod(Instance: TObject; ClassType: TClass;
    const MethodName: String; var Params: Variant): Variant;
    begin
    Result := 0;
    if MethodName = 'CELL.GET' then Result := .....

    ?

    H


  • edited 2:18AM
       if MethodName = 'CELLS.GET' then
          Result := TAdvStringGrid(Instance).Cells[Params[0], Params[1]]
        else if MethodName = 'CELLS.SET' then
          TAdvStringGrid(Instance).Cells[Params[0], Params[1]] := Params[2]
    

Leave a Comment