Topic: Tablegrid Header problem when using 'getrowatpos'

Hi All,
I hope someone can help.
Attached is an small program that demonstrates the issue
Scenario;
On Form1, the user presses 'mousedown' to make visible a panel containing a caller's message;  on 'mouseup' the panel is made invisible again.  This is much quicker than having to open Form 2 to view the message and then close Form 2 again (screenshot1 in the attachment).
Problem;
If the User wants to change the sort sequence of any column in the tablegrid, an error occurs (screenshot2 in the attachment).
Does anyone have any ideas how to fix this?  (application built using MVD Version 6.5 on Windows 10).
Thanks,
Derek.

Post's attachments

Attachment icon messages.zip 407.3 kb, 178 downloads since 2022-06-30 

2 (edited by domebil 2022-06-30 15:26:59)

Re: Tablegrid Header problem when using 'getrowatpos'

See if that's okay

Post's attachments

Attachment icon messages 2.rar 555.65 kb, 166 downloads since 2022-06-30 

Domebil

Re: Tablegrid Header problem when using 'getrowatpos'

Hi Domebil,
Thanks for having a look.
I originally tried to do it the way you are suggesting but it doesn't select the correct row (it selects the message from the previously selected row - or shows a blank message if it is the first row you mouse-down on).
Using mousedown with 'getrowatpos' fixes the issue of selecting the wrong message but then results in the problem when trying to sort the tablegrid.
Thanks,
Derek.

4 (edited by sparrow 2022-06-30 18:58:08)

Re: Tablegrid Header problem when using 'getrowatpos'

Hi Derek


An interesting idea. Try like this


  if form1.tablegrid1.getrowatpos(x,y) <> -1 then
    begin
        form1.panel1.visible := ...
        form1.label2.caption := ...
    end;

Re: Tablegrid Header problem when using 'getrowatpos'

A-Ha!  So that's how you do it.
That's excellent - it works perfectly now.
The program with Sparrow's fix is attached for anyone interested.
Thanks Sparrow,
Derek.

Post's attachments

Attachment icon messages fixed.zip 340.06 kb, 208 downloads since 2022-06-30 

6 (edited by sparrow 2022-06-30 19:54:12)

Re: Tablegrid Header problem when using 'getrowatpos'

Derek,
It was a little help...


But this is just an example)
For example, with pressing the shift key and only the left mouse button.
Does not interfere with opening Form2.

if (form1.tablegrid1.GetRowAtPos(x,y) <> -1) and (Shift) and (MouseLeft) then

But I also saw the hint GetRowAtPos (x, y) for myself. Just in time. Thank you.

Re: Tablegrid Header problem when using 'getrowatpos'

Hi Sparrow,
For what I need, I think that your suggestion of

if (form1.tablegrid1.GetRowAtPos(x,y) <> -1) and (Shift) then
    begin.....

is going to be the best solution.
Thanks again,
Derek