Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Strange behavior of StringGrid in Delphi 5.0.

Hi! I made GUI program which enable/disable the privilege of editing StringGrids. However, when I the first time run the rountine that enable user to edit the StringGrid, strange thing happen: the content in upper-left-corner cell of the first StringGrid disappeared. When click on that cell, the content appeared again. It will make the user not comfortable, but I don't know the reason.

Can you give me some idea about it?

Thank you!

When I click the button to enable the user to edit StringGrid, following code is related to StringGrid:
[code]
SetStringGrid(StringGrid_X,True,bsSingle,1,clWindowText);
SetStringGrid(StringGrid_Y,True,bsSingle,1,clWindowText);
[/code]

The SetStringGrid routine is compiled to another .DLL file:
[code]

procedure SetStringGrid(var G: TStringGrid; alive: Boolean; bs:TBorderStyle;
GridLineW: Integer; FontColor: TColor);
begin
if alive=False then begin
G.Options:=G.Options-[goEditing];
G.EditorMode:= False
end; {if} //always disable at first
G.BorderStyle:=bs;
G.GridLineWidth:=GridLineW;
G.Font.Color:=FontColor;
if alive=True then begin //always enable at last
G.Options:=G.Options+[goEditing];
G.EditorMode:= True;
end; {if}
end;{procedure SetStringGrid}
[/code]

Comments

  • earth_walkerearth_walker Posts: 184Member
    Hi! I find out the exect line which makes the problem. However, still don't know how to solve it, but bypass it with a method which should not be a good idea.

    following is my code in that routine, the line which makes the problem is [code]LinearDivisionViewerForm.FormStyle:= fsStayOnTop;[/code]
    I guess it is because computer redraws the background color of the focused cell and cover the string in it.

    Thank you!

    [code]
    procedure TLinearDivisionViewerForm.ModifyButtonClick(Sender: TObject);
    begin
    MainControlForm.SetAllEnabledValues(False);
    with LinearDivisionViewerForm do begin
    //Set up the buttons and Grids
    ModifyButton.Enabled:=False;
    ReloadMenuItem.Enabled:=False;
    CancelButton.Enabled:=True;
    OKButton.Enabled:=True;
    SetStringGrid(StringGrid_X,True,bsSingle,1,clWindowText);
    SetStringGrid(StringGrid_Y,True,bsSingle,1,clWindowText);
    end; // with
    //this line will make display error
    LinearDivisionViewerForm.FormStyle:= fsStayOnTop;
    StringGrid_X.Cells[1,1]:= IntToStr(XDivision[0].NumDiv); //patch
    LinearDivisionViewerForm.Enabled:= True;
    end; {procedure}
    [/code]

Sign In or Register to comment.