Topic: Memo Popup on Grid?

I was trying to add memo display on grid using mousedown event.

Found the following code from Dmitry for one of Derek's project:

procedure Form1_TableGrid1_OnMouseDown (Sender: string; MouseLeft, MouseRight, MouseMiddle: boolean; Shift, Alt, Ctrl: boolean; X, Y: Integer);
begin
  form1.memo1.Text := sqlexecute('select message from phonecalls where id =' +inttostr(Form1.TableGrid1.dbIndexToID(Form1.TableGrid1.GetRowAtPos(x,y))));
  form1.panel1.Visible := true;
end;

It works fine but when clicked on grid where a row doesn't contain data; it produces "List index out of bounds" message. Is there a way to eliminate it?

Adam
God... please help me become the person my dog thinks I am.

Re: Memo Popup on Grid?

Try this

procedure Form1_TableGrid1_OnMouseDown (Sender: string; MouseLeft, MouseRight, MouseMiddle: boolean; Shift, Alt, Ctrl: boolean; X, Y: Integer);
var
    iRow: integer;
begin
    iRow := Form1.TableGrid1.GetRowAtPos(x,y);
    if iRow > -1 then
    begin
        form1.memo1.Text := sqlexecute('select message from phonecalls where id =' +inttostr(Form1.TableGrid1.dbIndexToID(iRow)));
        form1.panel1.Visible := true;
    end;
end;
Dmitry.

Re: Memo Popup on Grid?

Hi Dmitry,


Great stuff as always.
Thank you very much..........
Truly appreciated..............

Adam
God... please help me become the person my dog thinks I am.

Re: Memo Popup on Grid?

Please provide a sample in project shape.

JUST LEARNING, O GOD HELP ME.