Link to home
Start Free TrialLog in
Avatar of Fordraiders
FordraidersFlag for United States of America

asked on

TAB key with DataGrid Control

What I need:
The Datagrid is 2nd in the Tab Sequence.


It seems that the cursor goes somewhere.
When I hit Tab again,  the correct object is in the next sequence.
But, when the datagrid is supposed to have focus,  I CAN'T see the cursor.


The datagrid is unbound.
I can mouse to the grid.


DataGrid2: settings
TabIndex2
TabStop  =  true
TabAction- =  Have tried all

Any help?
fordraiders
Avatar of Brendt Hess
Brendt Hess
Flag of United States of America image

Recommendation:  When the .Gotfocus event fires on your grid, set highlighting on the current row.  Your cursor will be visible then.
Avatar of Fordraiders

ASKER

bhess1,
Set highlighting?

When I used the mouse cursor to the firstRow , firstCell. and then proceeded to use the tab key ,
When I cycled back around to the grid It then obtained  focus.
However,
When I reached the last cell I got an error message.
"IRowOffset would position you past either end of the rowset, regardless of the cRows value specified; cRowsObtained  is 0"
Thanks
fordraiders

bHess1,
When I add a record to the Datagrid(which is what I'am trying to do at this point) . How do I set focus to the row that has the   * as indicating a new record?
Thanks
fordraiders
The easiest way would be to trap that error you got (IRowOffset), and add a new row to the grid at that point (DBGrid1.Rows = dbGrid1.Rows+1), then set focus to the new row (DBGrid1.Row = DBGrid.Rows - 2 ' if * line displayed - if not, then use -1)
bHess1,
I donot have a DBGrid.
I have a datagrid.
fordraiders
bHess1,
I donot have a DBGrid.
I have a datagrid.
fordraiders
bHess1,
I have had success(but not complete) so far with the following:

Private Sub DataGrid2_GotFocus()
IF (DATAGRID1.SELBOOKMARKS.COUNT <> 0 THEN
DATAGRID2.SELBOOKMARKS.REMOVE 0
END IF

IF ADODC3.RECORDSET.RECORDCOUNT = 0 _
AND DATAGRID2.ROW = 0 THEN
IF ADODC3.RECORDSET.RECORDCOUNT = 0 _
AND DATAGRID2.ROW = -1 THEN
Datagrid2.selBookmarks.add _ DATAGRID2.BOOKMARK
END IF
END IF
END SUB

I still have to right arrow but, I'am getting there.

If could simulate a LeftMouse click  AND a Left Arrow Keystroke  in the datagrid in a cell,  I could have it made.

fordraiders
Whoops! Datagrid (off MS Chart object), *NOT* DBGrid!   Bad Brendt, BAD Brendt! :)

I'll take a look, though.  Be back with any ideas...
bhess1,
I put a simple sendkeys "{right}"
In the got focus event.
This works o.k. for the first Tab around the form.
When it cycles back the cursor advances to the second cell.

This leads me to believe that after I use the right arrow the first time and then cycle back around the form THEN THE DATAGRID OBTAINS FOCUS WITHOUT CODE.  "Yes" This is what happens.

So when I use code the Datagrid on the second cycle Tabing ,  gives Focus to the second cell because it is already advancing to the first cell automatically.
????????
Hope this makes sense.!

fordraiders


ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Tim,
Works o.k.
How about Datagrid1 AND Datagrid3 Where a new record ISNOT allowed?
Thanks for looking at this question!!!
fordraiders



Tim,
This does not work when adding a new record.?
fordraiders
Comment accepted as answer