Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 To: Gerald Fay
  Where is Gerald Fay?
 Olympia
 Washington - United States
 Gerald Fay
 Tags
Subject: RE: Newbee and AddProperty form method
Thread ID: 288908 Message ID: 288958 # Views: 48 # Ratings: 2
Version: Visual FoxPro 9 SP2 Category: Forms
Date: Monday, December 27, 2010 11:25:32 AM         
   


> Interestingly, the second method does not respond to key input to locate the combobox items! All of the others do.
>
> Is it possible to add a new item with any of these methods and have the combobox text not disappear?
>

The previous sample was made a while ago, and actually as a matter of taste one intended purpose had been to indicate that RowSourceType=6 is not the most preferable one :-)


> I have coded with an array as the rowset to add an item if the combobox.text is not found.
> However when the valid method finishes the combobox text disappears, even when the text that was there was successfully added to the array and combobox list.
>
> Here is the code for the valid method for the combobox:
> ccity is the array of cities(1 dimensional) created using SQL Distinct.
>
> LOCAL i,city
> IF !EMPTY(THIS.Text)
> i=ASCAN(THISFORM.CCITY,UPPER(THIS.text))
> IF i=0
> DIMENSION THISFORM.CCITY[THIS.ListCount+1,1]
> =AINS(THISFORM.CCITY,THIS.LISTCOUNT)
> thisform.ccity[this.listcount]=UPPER(this.text)
> ASORT(thisform.ccity)
> endif
> ENDIF
>
> Is this.text (combobox) disappearing because the combobox.controlsource is the customer database city field?
> If I save this.text to a memvar and try to put it back into the blank combobox, I get a warning that the object, this.text is read only.
>
> How would you handle adding a new city to the combobox?
>
> You need to understand the nature of the customer base is local and there would be at most 100-200 cities. I think a separate database for cities would be overkill.
>

Your choice of course.
(My choice would be a separate "cities" table anyway, because coding becomes much easier that way, IMHO.)

As for the interactively-adding-rowsource-rows issue, I believe you are exactly on the right track, perhaps just an additional combo.Requery() required, see also sample pasted below.



hth
-Stefan




LOCAL oForm as Form
oForm = CREATEOBJECT('TestForm')
oForm.Show(1)
RETURN

DEFINE CLASS TestForm as Form
	AutoCenter = .T.
	DataSession = 2

	PROCEDURE Load
		CREATE CURSOR customers (cus_name C(30), cou_name C(30))
		INSERT INTO customers VALUES ('Arnaud', 'France')
		INSERT INTO customers VALUES ('Baldwin', 'UK')
		INSERT INTO customers VALUES ('Collins', 'USA')
		GO TOP IN customers
	ENDPROC

	ADD OBJECT cboCountries as ComboBox WITH Left = 50, Top = 50
	PROCEDURE cboCountries.Init
		This.AddProperty('aRowSource[3]')
		SELECT Distinct cou_name FROM customers INTO ARRAY This.aRowSource
		This.RowSourceType = 5
		This.RowSource = 'This.aRowSource'
	ENDPROC
	PROCEDURE cboCountries.Valid()
		IF ASCAN(This.aRowSource,TRIM(This.DisplayValue)) = 0
			DIMENSION This.aRowSource[ALEN(This.aRowSource,1)+1]
			STORE TRIM(This.DisplayValue) TO This.aRowSource[ALEN(This.aRowSource,1)]
			This.Requery()
		ENDIF
	ENDPROC

	ADD OBJECT txtDummy as TextBox WITH Left = 100, Top = 100, Valu = "focus dummy"
ENDDEFINE


ENTIRE THREAD

Newbee and AddProperty form method Posted by Gerald Fay @ 12/25/2010 9:27:55 PM
RE: Newbee and AddProperty form method Posted by Stefan Wuebbe @ 12/25/2010 11:15:20 PM
RE: Newbee and AddProperty form method Posted by Gerald Fay @ 12/26/2010 6:33:49 PM
RE: Newbee and AddProperty form method Posted by Stefan Wuebbe @ 12/26/2010 9:02:07 PM
RE: Newbee and AddProperty form method Posted by Samir H. @ 12/27/2010 2:22:52 AM
RE: Newbee and AddProperty form method Posted by tushar @ 12/27/2010 5:11:48 AM
RE: Newbee and AddProperty form method Posted by Stefan Wuebbe @ 12/27/2010 10:56:04 AM
RE: Newbee and AddProperty form method Posted by Samir H. @ 12/27/2010 11:57:12 AM
RE: Newbee and AddProperty form method Posted by Ony Too @ 12/27/2010 2:13:01 PM
RE: Newbee and AddProperty form method Posted by Samir H. @ 12/27/2010 2:56:32 PM
RE: Newbee and AddProperty form method Posted by Ony Too @ 12/28/2010 6:36:49 AM
RE: Newbee and AddProperty form method Posted by Samir H. @ 12/28/2010 8:03:04 AM
RE: Newbee and AddProperty form method Posted by Cetin Basoz @ 12/27/2010 10:59:11 AM
RE: Newbee and AddProperty form method Posted by Samir H. @ 12/27/2010 11:54:00 AM
RE: Newbee and AddProperty form method Posted by Cetin Basoz @ 12/27/2010 6:04:34 PM
RE: Newbee and AddProperty form method Posted by Gerald Fay @ 12/27/2010 7:08:38 AM
RE: Newbee and AddProperty form method Posted by Stefan Wuebbe @ 12/27/2010 11:25:32 AM
RE: Newbee and AddProperty form method Posted by Jun Tangunan @ 12/28/2010 3:40:59 AM
RE: Newbee and AddProperty form method Posted by Samir H. @ 12/28/2010 3:54:37 AM
RE: Newbee and AddProperty form method Posted by Stefan Wuebbe @ 12/28/2010 7:33:01 AM
RE: Newbee and AddProperty form method Posted by Jun Tangunan @ 12/28/2010 8:05:48 AM
RE: Newbee and AddProperty form method Posted by Stefan Wuebbe @ 12/28/2010 10:28:42 AM
RE: Newbee and AddProperty form method Posted by Jun Tangunan @ 12/29/2010 12:19:48 AM
RE: Newbee and AddProperty form method Posted by Cetin Basoz @ 12/29/2010 1:41:27 AM
RE: Newbee and AddProperty form method Posted by Jun Tangunan @ 12/29/2010 2:11:57 AM
RE: Newbee and AddProperty form method Posted by Stefan Wuebbe @ 12/29/2010 2:20:14 PM
RE: Newbee and AddProperty form method Posted by Cetin Basoz @ 12/29/2010 2:39:39 PM
RE: Newbee and AddProperty form method Posted by Samir H. @ 12/29/2010 3:08:48 PM
RE: Newbee and AddProperty form method Posted by Cetin Basoz @ 12/30/2010 9:32:09 AM
RE: Newbee and AddProperty form method Posted by Jun Tangunan @ 12/29/2010 11:42:07 PM
RE: Newbee and AddProperty form method Posted by Gerald Fay @ 12/28/2010 8:25:03 AM
RE: Newbee and AddProperty form method Posted by Stefan Wuebbe @ 12/28/2010 10:31:14 AM
RE: Newbee and AddProperty form method Posted by Ony Too @ 12/26/2010 6:00:33 AM
RE: Newbee and AddProperty form method Posted by Gerald Fay @ 12/27/2010 2:01:43 AM
RE: Newbee and AddProperty form method Posted by Cetin Basoz @ 12/27/2010 10:51:52 AM
RE: Newbee and AddProperty form method Posted by Anders Altberg @ 12/26/2010 7:20:37 PM
RE: Newbee and AddProperty form method Posted by Jun Tangunan @ 12/28/2010 3:44:21 AM
RE: Newbee and AddProperty form method Posted by Gerald Fay @ 12/28/2010 8:55:49 AM
RE: Newbee and AddProperty form method Posted by Anders Altberg @ 12/29/2010 5:23:29 PM
RE: Newbee and AddProperty form method Posted by Jun Tangunan @ 12/29/2010 11:57:08 PM
RE: Newbee and AddProperty form method Posted by Anders Altberg @ 12/30/2010 10:12:32 AM
RE: Newbee and AddProperty form method Posted by Jun Tangunan @ 12/28/2010 6:31:22 AM
RE: Newbee and AddProperty form method Posted by Gerald Fay @ 12/28/2010 8:37:18 AM
RE: Newbee and AddProperty form method Posted by Ron Seidl @ 2/16/2014 4:54:41 PM