Strange behavior of StringGrid in Delphi 5.0. - Programmers Heaven

Howdy, Stranger!

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

Categories

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.