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

ListBox and EditBox controls

Status
Not open for further replies.

mensud

Programmer
Jul 22, 2001
51
0
0
US
Hello,

I have very, very stupid situation. I am working with ListBox and EditBox controls. What I am trying to do is very simple. When I type something in textbox and after pressing enter button, I want this to be showned upo in my tlistbox, and KEEP FOCUS on editbox, so I can enter another value. I tried a few solutions and does not work. Please, respond with your solution ...
 
Add a property to the form call it nCounter and make its value to be 0
in the Keypress Event of the textbox
if nKeyCode = 13
if not empty(this.value)
Thisform.nCounter = Thisform.nCounter + 1
Thisform.AddListItem(this.value,Thisform.nCounter)
endif
endif

In the GotFocus Event from the listbox.
Thisform.Textbox1.Setfocus() return the focus to the textbox

Ali Koumaiha
TeknoSoft Inc
Farmington Hills, Michigan
 
Code:
CLEAR
CLEAR ALL

obj = CREATEOBJECT('Tform')
obj.Show(1)

DEFINE CLASS Tform As Form
	Width=500
	Height=300
	Autocenter=.T.
	
	ADD OBJECT txt As TextBox WITH;
	Left=20, Top=20, Width=200, Height=23,;
	Format='K'
	
	* TabStop=.F. does the job
	ADD OBJECT lst As ListBox WITH;
	Left=20, Top=54, Width=460, Height=200,;
	TabStop=.F.

PROCEDURE txt.Valid
	IF NOT EMPTY(THIS.Value)
		ThisForm.lst.AddItem(RTRIM(THIS.Value))
	ENDIF
ENDDEFINE

Anatoliy Mogylevets
1361529 Ontario, Inc.
Scarborough, ON, Canada
 
I like the post by tek2tips, only modified slightly. In the valid event of the text box:
Code:
IF !Empty(this.Value)
   Thisform.list1.Addlistitem(This.Value)
   This.Value = ''
   RETURN 0
ENDIF


-Dave S.-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top