#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    28
    Rep Power
    0

    Apply Changes for TMS grid ?


    During the insert funtion in TMS grid,a column needs to be change as Read only based on the input of the previous column of the same grid..
    Is it possible ?

    Thanks in advance.....
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,057
    Rep Power
    383
    Of course.
    I suggest you put the necessary code in a method and then figure out from which of the grid's many events it should be called.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    5
    Rep Power
    0
    You can use the OnCanEditCell procedure to do this. Here is an example.

    procedure TfrmFormulation.FormulaGridCanEditCell(Sender: TObject; ARow,
    ACol: Integer; var CanEdit: Boolean);
    begin
    if StringGrid.Cells[1,StringGrid.Row] = 'Whatever' then
    canedit := ((ACol=1) or (ACol=3))
    else
    canedit := ((ACol=1) or (ACol=2));
    end;
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,057
    Rep Power
    383
    If CanEditCell will handle all situations as Brandy333 suggests, then, based upon your criteria you may find
    code more like this to be closer to what you want:
    Code:
    procedure TfrmFormulation.FormulaGridCanEditCell(Sender: TObject; ARow,
    ACol: Integer; var CanEdit: Boolean);
    begin
        // First test for column 0 - 
        // or whatever column represents your first editable column (??)
        if ACol < ?? then begin
           // do whatever you need to do
        end
        else begin
           if StringGrid.Cells[(ACol-1),ARow] = 'Whatever' then
               canedit := False
           else
               canedit := True;
        end; 
    end;
    Clive
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    28
    Rep Power
    0
    I got the exact output...
    Thanks a lot Brandy333 , clive.

IMN logo majestic logo threadwatch logo seochat tools logo