Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21839

MsFlexGrid - Differentiate navigation trigger: mouse or keyboard!

$
0
0
Hi guys,

I am having a strange problem! I am using MsFlexGrid to list some values.

First, I wanted to detect in the MsFlexGrid if an arrow-key is pressed (left, right, up and down). After some research, I found out there are some problems to do so because the arrow keys actually "navigate" through the list, instead of sending the key code/value. I tried KeyPress/KeyDown/KeyUp/SelChange and some others, but no one of those seem to work.

After finding out that could be tricky to implement, then I just tried to detect using the SelChange: if the row and col of the grid is changed to an adjacent one (a cell at right/left/below or above), revert it back to prevent the movement (because in my case it should have been a complete selection of a cell, or nothing at all; arrow keys will just "point" to an adjacent cell by putting a border around it, but does not select it).

This has worked well, if a cell is selected in the grid, then a arrow key is pressed, it is reverted back and does not change anything (what I want). But I am having a new problem, I just wanted to prevent keyboard arrow keys to be reverted, but now if a cell is selected, and a user clicks on an adjacent cell using the mouse, it is still considered in the SelChange and reverts back the move (what I don't want!), in my program, users should be able to use the mouse to traverse to any cell of the grid.

So any idea for the questions is appreciated. Either to solve the first question: detecting arrow keys pressed, or the second: how to detect if the cell is changed due to mouse click or keyboard arrow key.

If the problem is not comprehensive enough, let me know and I will post photos.

Viewing all articles
Browse latest Browse all 21839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>