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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP7 clear text field if starting to key 2

Status
Not open for further replies.

bettyfurr

Technical User
Mar 12, 2002
371
US

The user tabs around the fields to get another field.

These fields are always enabled for editing. Sometimes they want to change a field.

Sometimes they are starting in field1 to change field1. The contents of field1 needs to be removed when they start to key in field1 for the new data. Now it just scoots over and is left in the field, if the user does not delete it.

Sometimes they are starting in field1 and tabbing to field2 to change field2. The contents of field1 needs to stay.

Please help.

Betty :-(

 
There are all kinds of problems that I can see with a design like this. You are going to have some problems to overcome and some decisions to make here. But that having been said, you can start by putting some code in the Keypress event of the textboxes, or your subclass of the textbox. The code should check the nKeyCode parameter (i think that is it's name, not looking right now) and if it is not a tab (9) then you will blank out your field. However that is just a start...you will need to handle the backspace, the delete, and a number of other keys depending on what behavior you want, you will need to figure out when you are going to blank the textbox's value out and when you won't (such as just the first time, or just on tab or click into the texbox)...that is just a few of the things you will run into. Straying this far from Window's UI conventions is sometimes more trouble than it's worth.

Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 


Change the selectonentry property of the textbox to .t.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
The user tabs around the fields to get another field.

Mike,
Wouldn't this swipe out the contents everything they tab into the field?

Change the selectonentry property of the textbox to .t.

Betty :-(
 
Put the format for the textbox: @K

that would take care of it
:)

Ali Koumaiha
TeknoSoft Inc
Farmington Hills, Michigan
 
Mike,

I guess sometimes two people can read the same question and be thinking of two entirely different things. I think you may be on to something there. [smile]

Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
bettyfurr

Wouldn't this swipe out the contents everything they tab into the field?

Have you tried it? No it does not wipe the content when you tab, only when you start typing something. Here is an example, try it yourself.
Code:
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"
	ADD OBJECT text1 AS textbox WITH ;
		ControlSource = "mycursor.name", ;
		Height = 23, ;
		Left = 48, ;
		SelectOnEntry = .T., ;
		Top = 36, ;
		Width = 100, ;
		Name = "Text1"
	ADD OBJECT text2 AS textbox WITH ;
		ControlSource = "mycursor.address", ;
		Height = 23, ;
		Left = 132, ;
		SelectOnEntry = .T., ;
		Top = 96, ;
		Width = 100, ;
		Name = "Text2"
	ADD OBJECT text3 AS textbox WITH ;
		ControlSource = "mycursor.city", ;
		Height = 23, ;
		Left = 204, ;
		SelectOnEntry = .T., ;
		Top = 156, ;
		Width = 100, ;
		Name = "Text3"
	PROCEDURE Load
		CREATE CURSOR myCursor (name c(10),address c(10),city c(10))
		INSERT INTO myCursor (name,address,city) VALUES ("Mike","123","Tokyo")
		GO top
	ENDPROC
ENDDEFINE

SlightHaze

I guess sometimes two people can read the same question and be thinking of two entirely different things

That is what VFP is all about!

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thanks, Guys.

The select on entry works great if they tab into the field. You know there is always an however with VFP. However, if they click into it, it does not select the contents.

Help!

Betty :-(
 
Betty,

You are right. However you should also know there is always a workaround with VFP :-D

Put this code in Textbox.Click event:

This.SelStart = 0
This.SelLength = len(alltrim(This.Value))

Hope it helps

-- AirCon --
 
Thank you AirCon,

Will try the code tonight. Stars tomorrow for help.

Betty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top