adding properties of stringgrid

edited 8:02AM 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 8:02AM
    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 8:02AM
    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 8:02AM
       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

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.