Link to home
Start Free TrialLog in
Avatar of ctjoumas
ctjoumas

asked on

Double-clicking a frozen column/row

I am using a TStringGrid and want to be able to select a record when the user double clicks a gray frozen column/row.  TStringGrid cannot, I suppose, receive focus on a frozen cell - so the unwanted behavior that occurs is that when a frozen cell is double-clicked, the currently highlighted record is displayed.  Is there any way that I can select the record that is double-clicked when double-clicking a frozen cell?

Thanks,

Chris
ASKER CERTIFIED SOLUTION
Avatar of mocarts
mocarts

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ctjoumas
ctjoumas

ASKER

Thanks for the reply.  Ok, here is what I have (I only want to select *one* row):

With sgdGrants.ScreenToClient(Mouse.CursorPos) Do
Begin
  sgdGrants.MouseToCell(X, Y, C, R);

  // we want to select this row (R)
  If (C < sgdGrants.FixedCols) Then
  Begin
    gr.Left := sgdGrants.FixedCols;
    gr.Right := sgdGrants.ColCount;
    gr.Top := R;
    gr.Bottom := R;
    sgdGrants.Selection := gr;
  End;
End;

This works fine, but there is one problem (that I'm still looking in to) - after I select a row using the above code and then try to scroll down using the mouse wheel, I get an "EInvalidGridOperation with message 'Grid index out of range'".

Am I doing anything strange here?

Thanks,

Chris
Thanks for the reply.  Ok, here is what I have (I only want to select *one* row):

With sgdGrants.ScreenToClient(Mouse.CursorPos) Do
Begin
  sgdGrants.MouseToCell(X, Y, C, R);

  // we want to select this row (R)
  If (C < sgdGrants.FixedCols) Then
  Begin
    gr.Left := sgdGrants.FixedCols;
    gr.Right := sgdGrants.ColCount;
    gr.Top := R;
    gr.Bottom := R;
    sgdGrants.Selection := gr;
  End;
End;

This works fine, but there is one problem (that I'm still looking in to) - after I select a row using the above code and then try to scroll down using the mouse wheel, I get an "EInvalidGridOperation with message 'Grid index out of range'".

Am I doing anything strange here?

Thanks,

Chris
I provided code referencing Q title i.e. clicking on column/row :)
what you exactly want to do? maybe you can use simpe goRowSelect Option of grid? and set row when double clicked on FixedCol?
or you want to edit content of grid and this row select is needed only as such behaviour of grid?
mo.
The code you posted was fine - I just needed the small part of it though (what I have posted) to do what I want.  All I want to happen is when someone clicks or double clicks on a frozen cell, the corresponding row should be highlighted.  This is working now...thanks :)

Chris