×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Grid Navigation
2

Grid Navigation

Grid Navigation

(OP)
I have a grid on a form which contains fields from a single cursor. The users are used to vertical textboxes where the navigation would basically go down a column. Now the navigation stays on the same row (when pressing ENTER), moving horizontally. Is there a simple way to change this, or is it just a training issue, i.e., using the down arrow key with set confirm on?

RE: Grid Navigation

Hi tkee,

it is possible, to navigate to a certain column in a certain row programmatically (have a look at 'ActivateCell'), but....as soon as your grids properties allow to move or hide columns at runtime, programmatic navigation isn't fun anymore.

To be honest, when grids where introduced in VFP in the mid 90s I jumped at them with a vengeance for using them for data input. Nowadays, they do nothing but visualize data and select data in my apps. This gives me way more freedom in using containers and multiline rows and on row selection, another part of the form shows a regular data entry that is bound to the same cursor as the grid.

JM2C

-Tom
https://www.blogger.com/profile/089031659767875220...

RE: Grid Navigation

ON KEY LABEL ENTER KEYBOARD "{DNARROW}" PLAIN

Don't forget to ON KEY LABEL ENTER to reset it after you're done.

Mike Yearwood - Former FoxPro MVP

RE: Grid Navigation

Are they perhaps used to EDIT windows? You can also turn a grid to that vertical orientation by setting GRID.VIEW = 1. It's not the best overview, if you ask me. But it's also what you get by EDIT or CHANGE command. Als, the FREEZE feature isn't available anymore, if you'd like to have a single column editable, but you can make columns unselectable by putting RETURN .F. into their WHEN event.

Chriss

RE: Grid Navigation

Mike Y has given you a good solution. However, in general I prefer to avoid using ON KEY LABEL, because it is a global setting that will affect the entire application rather than just the grid.

The alternative is to use the KeyPress events of the individual textboxes (within the columns). So, in the KeyPress of Grid.Column1.Text1, you would do this:

CODE -->

LPARAMETERS nKeyCode, nShiftAltCtrl

IF nKeyCode = 13
  NODEFAULT 
  KEYBOARD '{DNARROW}'
ENDIF 

You would then do the same thing in the KeyPresses of the textboxes within all the columns.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Grid Navigation

Hi,

In addition to what Mike Lewis suggested you may want to create your own TextBox subclass with the wanted behavior(s) (see code below) and add them to your grid

CODE -->

**************************************************
PUBLIC goForm

goForm = NEWOBJECT("frmForm")
goForm.Visible = .T.
goForm.Show

Read Events
Close all
Clear All
RETURN


**************************************************
DEFINE CLASS txtEnterBox as TextBox
	BackColor = RGB(75, 255, 255)
	FontBold = .T.
	
	PROCEDURE KeyPress()
		LPARAMETERS nKeyCode, nShiftAltCtrl

		IF nKeyCode = 13
			NODEFAULT 
			KEYBOARD '{DNARROW}'
		ENDIF
	ENDPROC 
ENDDEFINE

DEFINE CLASS frmForm AS Form
	AutoCenter = .T.
	Caption = "Cities"
	ShowTips = .T.
	Height = 360
	Width = 648
	MinHeight = This.Height
	MinWidth = This.Width

	
	ADD OBJECT grdCities AS Grid WITH ;
		BackColor = RGB(125, 255, 255), ;
		DeleteMark = .F., ;
		Left = 12, ;
		Top = 12, ;
		Width = 648 - 24, ;
		Height = 360 - 24, ;
		RowHeight = 24, ;
		AllowRowSizing = .F., ;
		Anchor = 15, ;
		Themes = .F., ;
		Visible = .T., ;
		ColumnCount = -1, ;
		RecordSource = "curCities"
		
		PROCEDURE grdCities.Init()
			WITH This.Column1
				.Header1.Caption = "City"
				.Header1.FontBold = .T.
				.Width = 120
				.Resizable = .F.
				.NewObject("txtCity","txtEnterBox")
				.CurrentControl = "txtCity"
				.txtCity.Visible = .T.
				.Sparse = .F.
			ENDWITH 

			With This.Column2
				.Header1.Caption = "Country"
				.Header1.FontBold = .T.
				.Width = 60
				.Resizable = .F.
				.NewObject("txtCountry","txtEnterBox")
				.CurrentControl = "txtCountry"
				.txtCountry.Visible = .T.
				.Sparse = .F.
			ENDWITH    	
		ENDPROC 

	PROCEDURE Load()
		CREATE CURSOR curCities (cCity C(25), cCountry C(2))

		INSERT INTO curCities VALUES ("New York", "US")
		INSERT INTO curCities VALUES ("Moscow", "RU")
		INSERT INTO curCities VALUES ("Paris", "FR")
		INSERT INTO curCities VALUES ("Berlin", "GE")
		INSERT INTO curCities VALUES ("London", "GB")
		INSERT INTO curCities VALUES ("Den Haag", "NL")
		
		LOCATE 
	ENDPROC 
	
	PROCEDURE Destroy
		CLOSE ALL
		Clear Events
	ENDPROC

ENDDEFINE

********************************************* 

hth

marK

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close