Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combobox haunting
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Combobox haunting
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01065083
Message ID:
01065083
Views:
51
Hi everybody,

I guess I would write about this problem till the end of my days.

Our combobox class "thinks" that something was changed even after I press the Cancel button.

I have a simple form with a cboFrequency on the form. This combo is bound to the field of the table. I select the value from the combo, then press Cancel button of the form that does tablerevert and refresh(). Now when I want to leave the form I see a dreadful question "Do you want to save your changes?" The same story as we're having in another much more complex form and the same problem we were having in other forms but somehow resolved. Also at the same form if I check Immediate request checkbox, I set the cboFrequency.value = 'ONCE'. In this case it also gives me a question when I hit Cancel and then close.

In other words, it looks like if the value (or DisplayValue) of the combobox that is bound to a control was changed either interactively or programmatically, the combobox "thinks" something was changed even if the changes are already reverted or saved.

Here is my combobox Initialize code (called from its Init):
*---------------------- Location Section ------------------------
*   Library: 	Acustomcontrols.vcx
*   Class: 		Cboviscodes
*   Method: 	Initialize()
*----------------------- Usage Section --------------------------
*)  Description:
*)

*   Scope:      Public
*   Parameters:
*$  Usage:
*$
*   Returns:
*--------------------- Maintenance Section ----------------------
*   Change Log:
*       CREATED 	11/02/2005 - WGB
*		MODIFIED
*----------------------------------------------------------------
#define CRLF chr(13) + chr(10)

local lnSelect, lnRows, lnCols, laFields[1]
lnSelect = select() && Save current alias
with this
	lcCategory = .cCategory_Description
	lcSubcategory = .cSubcategory_Description
	lcDept = m.goApp.cDept
** Make sure we always have data even in the wrong case
	dimension .aRowSource [1, 3]
	.aRowSource [1,1] = "<<No data returned>>"

	store "" to .aRowSource [1, 2], .aRowSource [1, 3]

	if empty(.cCursorName)
		.cCursorName = "c_VisCodesLookup"
	endif

	if not empty(m.lcCategory) && no point to execute the code if Category is empty
		if (.lDisplayAllRecords and Get_Viscodes_Records_By_Category(m.lcCategory, m.lcSubcategory, ;
				m.lcDept, .cCursorName , .f.)) ;
				or Get_description_from_Viscodes(m.lcCategory, m.lcSubcategory, ;
				m.lcDept, .cCursorName , .f., .lSystemFlag)

			lnRows = reccount(.cCursorName)

			if m.lnRows > 0 && our cursor does have rows

				select (.cCursorName)
				lnCols = afields(laFields)
				dimension .aRowSource [m.lnRows, m.lnCols]
				copy to array .aRowSource

				select (m.lnSelect)

				if .lAddBlank
					dimension .aRowSource[ALEN(.aRowSource,1)+1, m.lnCols] && add one more row
					ains(.aRowSource,1) && inserts a row
					for lnI =1 to m.lnCols
						store space(1) to .aRowSource [1, m.lnI]
					next
				endif

				if .lAddAll
					dimension .aRowSource[ALEN(.aRowSource,1)+1, m.lnCols] && add one more row
					ains(.aRowSource,1)
					for lnI =1 to m.lnCols
						store iif(m.lnI = 1, "<<All>>", "%") to .aRowSource [1, m.lnI]
					next
				endif

				if .lAddAll or .lAddBlank
					.listindex = 1
				endif
			else
				=ErrorMsg("The control " + .name + " does not return records. " + CRLF + ;
					"Please, contact the system administrator")
			endif
			if not .lSaveCursor
				use in select(.cCursorName)
			endif
			.AdjustWidth()
		else
			=ErrorMsg("The control " + .name + " is not set up correctly. " + CRLF + ;
				"Please, contact the system administrator")
		endif
	endif
	.rowsourcetype = 5 && Array
	.rowsource = "This.aRowSource"
endwith
Do you see what is wrong here? The controlsource for the combo is set in the property sheet. If I try to set it after Init, it usually resolves the problem.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform