Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Display combo with no selection
Message
 
 
À
27/06/2005 13:51:45
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01026750
Message ID:
01026790
Vues:
18
Hi Marcia,

Here is a code from my method, which initializes combos. Look for cboEmployees. I was trying to use ListIndex, but it didn't work: [Also there are few values in Users table with empty cUserID, but not empty cEmpName]
*---------------------- Location Section ------------------------
*   Library: 	Aformsqueuemgmt.vcx
*   Class: 		Frmsupervisorqueuemgt
*   Method: 	Initializecombos()
*----------------------- Usage Section --------------------------
*)  Description:
*)

*   Scope:      Public
*   Parameters:
*$  Usage:
*$
*   Returns:
*--------------------- Maintenance Section ----------------------
*   Change Log:
*       CREATED 	06/23/2005 - NN
*		MODIFIED
*----------------------------------------------------------------
lparameters tcDeptAlias, tcTeamAlias, tcEmployeeAlias
local lnLeft, lnTop, lnWidth
with thisform
	if .cboDepartments.lReadonly
		lnLeft = .cboDepartments.left
		lnTop = .cboDepartments.top
		lnWidth = .cboDepartments.width
		.cboDepartments.release()
		.newobject('txtDepartment', 'cTextbox')
		.txtDepartment.readonly = .t.
		.txtDepartment.lReadonly = .t.
		.txtDepartment.value = .cDepartmentName
		.txtDepartment.left = m.lnLeft
		.txtDepartment.top = m.lnTop
		.txtDepartment.width = m.lnWidth
		.txtDepartment.visible = .t.
	else
		.cboDepartments.rowsourcetype = 3
		.cboDepartments.rowsource = ;
			"SELECT distinct cDepartment_name, cDepartments_pk " + ;
			"FROM " + m.tcDeptAlias + ;
			" INTO CURSOR c_AllDepartments " + ;
			"ORDER BY 1"
		if not inlist(.oBizObj.cDepartments_pk,space(16),"%")
			.cboDepartments.value = .oBizObj.cDepartments_pk
		endif
		.cboDepartments.controlsource = .oBizObj.cDepartments_pk
	endif

	if .cboTeams.lReadonly
		lnLeft = .cboTeams.left
		lnTop = .cboTeams.top
		lnWidth = .cboTeams.width
		.cboTeams.release()
		.newobject('txtTeam', 'cTextbox')
		.txtTeam.readonly = .t.
		.txtTeam.lReadonly = .t.
		.txtTeam.value = .cTeamName
		.txtTeam.left = m.lnLeft
		.txtTeam.top = m.lnTop
		.txtTeam.width = m.lnWidth
		.txtTeam.visible = .t.
	else
		.cboTeams.rowsourcetype = 3
		.cboTeams.rowsource = ;
			"SELECT distinct cTeam_name, cEmployee_teams_pk " + ;
			"FROM "+ m.tcTeamAlias  + ;
			" INTO CURSOR c_AllTeams " + ;
			"ORDER BY 1"
		if not inlist(.oBizObj.cEmployee_teams_pk,space(16),"%")
			.cboTeams.value = .oBizObj.cEmployee_teams_pk
		endif
		.cboTeams.controlsource = .oBizObj.cEmployee_teams_pk
	endif

	if .cboEmployees.lReadonly
		lnLeft = .cboEmployees.left
		lnTop = .cboEmployees.top
		lnWidth = .cboEmployees.width
		.cboEmployees.release()
		.newobject('txtEmployee', 'cTextbox')
		.txtEmployee.readonly = .t.
		.txtEmployee.lReadonly = .t.
		.txtEmployee.value = .cEmployeeName
		.txtEmployee.left = m.lnLeft
		.txtEmployee.top = m.lnTop
		.txtEmployee.width = m.lnWidth
		.txtEmployee.visible = .t.
	else
		.cboEmployees.rowsourcetype = 3
		.cboEmployees.rowsource = ;
			"SELECT distinct cEmpName, cUserID " + ;
			"FROM " + m.tcEmployeeAlias + ;
			" INTO CURSOR c_AllEmployees " + ;
			"ORDER BY 1"
		if not empty(.oBizObj.cEmployeeID)
			.cboEmployees.value = .oBizObj.cEmployeeID
		else
			.cboEmployees.value = "does not exist" && we want to start with no selection
		endif
		.cboEmployees.controlsource = .oBizObj.cUserID
	endif
endwith
>Hi Nadya.
>
>I have a combobox with a value bound to a property. I'd like to be able to start with no value selected. However, I don't have empty value in the list and I do not want to add it there. Is there any way to make it work as I want? Right now it always shows a value even if I try to set ListIndex = 0 and DisplayValue = "".
>
>You must have code somewhere that is doing this. I just tested with a base class form and a base class combo box and setting the comb box's ListIndex to 0 in the form's Init displays a blank value in the combo.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform