Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grid and selected workarea

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hi!

Once I click in a grid the workarea of the grid is selected. (correct me when wrong).

How can I go back to the workarea which was used before clicking in the grid while the grid(or one of its members) still has focus?

KR
-Bart
 
Bart,

I believe that when you populate your grid's datasource with the grids's correct cursor or table or statement your workarea will not change. It seems to me there is something else going on, what is your exact problem?
Jockey(2)
 
Hi!
The grid is populated from an parametrized view.
The remaining controls from another datasource.

Once I click in the grid the workarea is changed.

Than I do a skip (via code using mousewheel which is bound to form-method)

As the selected workarea than is not the original workarea skipping takes place through the grid iso the 'base' table.

-Bart
 
Bart,

Than I do a skip ... As the selected workarea than is not the original workarea skipping takes place through the grid iso the 'base' table.

You are right that clicking on a grid causes the selected work area to change. I don't know whether this is a bug or is by design. Either way, it's a well-known behaviour.

The solution is to write code in the grid's When event to store the value of ALIAS(). When the When event fires, the correct work area will still be selected. You can then reference the stored value in your SKIP.

For example:

Code:
* In the grid's When
THISFORM.cAlias = ALIAS()

* In the grid's Mousewheel (or other) event
IF NOT EMPTY THISFORM.cAlias
  SKIP IN (THISFORM.cAlias)
ENDIF

Hope this helps.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike,
Sorry to say: does not work.
I have a skipforward and similar skipbackwards method in the form.
This looks like:
Code:
* skip forward
LPARAMETERS tBottom
LOCAL llOK, lnOldSelect, lcPrimTable
llOK = .T.
WITH this
	IF !thisform.lCanNavigate
		RETURN
	ENDIF
		.saveForm()		
		
		lnOldSelect = SELECT()
		IF !EMPTY(.cPrimairytable)
			.beforeskip()
			
			SELECT (.cPrimairyTable)

			
			IF tBottom
				GO BOTTOM 
			ELSE 
				IF !EOF()	
					SKIP IN (.cPrimairytable)
				ENDIF 
			ENDIF 

			IF EOF()
				GO Bottom
				=.message(MSG_LAST_REC,WHITE,BLACK,.Left,.width,.height)
			ENDIF

			.afterskip()	

			.refreshform()
		ENDIF 
		SELECT (lnOldSelect)
		
		
ENDWITH
Formproperty cPrimairyTable holds the name of the table which I like to skip always in using this method.

In the grid's init method I put code:
Code:
	IF .lBindMousewheelToForm
		Bindevent(This,"MouseWheel",Thisform,"MouseWheel")
	ENDIF
Code as you mentioned to place in whenmethod seems not required to me.
To complete the code; this is in mouswheel-event of form:
Code:
*MouseWheel
LPARAMETERS nDirection, nShift, nXCoord, nYCoord
WITH thisform 
	IF nDirection < 0
		.skipforward
	ENDIF
	IF nDirection > 0
		.skipback
	ENDIF
ENDWITH
This code is in all form-controls and works in normal fine.

Any other sugestion?

-Bart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top