Your 'c' variable is initialized to 0, which is likely why your column 0 gets highlighted at startup. Initialize the variable to -1 instead, and then update it on mouse clicks as needed.
Also, you don't need to use the OnSelectCell event at all, just let the OnMouseDown code determine the column using the provided X/Y coordinates.
Also, DO NOT call your OnDrawCell event handler direct!y. Let the system call it for you when the Grid actually needs to be painted naturally.
Try something more like this instead:
implementation
var
HighlightedColumn: Integer;
...
procedure TForm1.FormCreate(Sender: TObject);
begin
HighlightedColumn := -1;
end;
procedure TForm1.sg1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (ACol = HighlightedColumn) then begin
sg1.Canvas.Brush.Color := clBlue;
sg1.Canvas.FillRect(Rect);
end;
end;
procedure TForm1.sg1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
c, r: Longint;
begin
sgl.MouseToCell(X, Y, c, r);
if (r < sgl.FixedRows) then begin
HighlightedColumn := c;
sg1.Invalidate;
end;
end;