We help IT Professionals succeed at work.

MSFlexgrid Problems with selection

BJStearn
BJStearn asked
on
Hi,
I've got a grid and I want to pop up a menu on right-click. The menu contents depends on the row contents.

I had it activated in MouseDown event but that had the problem that the old selection is still intact, NOT the selected row where the user clicked. I *HAD* the same issue with a TreeView but this was solved by changing it to the MouseUp event, i.e. it appears the selection takes place between MouseDown and MouseUp *SO* the correct element is selected prior to the menu creation.

This DOES NOT happen with the MSFlexGrid

Any suggestions

BJ
Comment
Watch Question

Commented:
I think U get X,Y Position in that event

DO NOT USE    Row,Col of CELL

USE X,Y To get current mouse position
Use .MouseRow and .MouseCol properties to change the selection during whilst trapping the right-click in the _MouseDown event...

Author

Commented:
To: Bahnass
Yes but it's allways anoyed me that there is no easy translation from X,Y to Row/Col especially when it's been scrolled. I was hoping for a way of provoking the grid to do the same as TreeView and behave 'properly'. I'll look into the two answers but won't get back till monday (it's 21:30pm in Australia)

BJ

Author

Commented:
To: Bahnass
Yes but it's allways anoyed me that there is no easy translation from X,Y to Row/Col especially when it's been scrolled. I was hoping for a way of provoking the grid to do the same as TreeView and behave 'properly'. I'll look into the two answers but won't get back till monday (it's 21:30pm in Australia)

BJ

Author

Commented:
Spot on, don't know how I missed that one but thanks.
BJ

Explore More ContentExplore courses, solutions, and other research materials related to this topic.