Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to know a ListItem in ComboBox is disabled?
Message
De
22/08/2019 12:17:29
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
22/08/2019 11:34:00
Joe Kaufman
Bell Laboratories Inc.
Wisconsin, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
01670243
Message ID:
01670256
Vues:
74
That didn't really answer my question. It is harder when you don't have some code to replicate the problem. Anyway:
Public oForm
oForm = Createobject('myForm')
oForm.Show

Define Class myForm As Form
	DataSession = 2
	Top = 0
	Left = 0
	Height = 271
	Width = 411
	DoCreate = .T.
	Caption = "Combo test"
	Name = "frmMyForm"
	Dimension arrItems[1]

	Add Object cmbSample As ComboBox With ;
		BoundColumn = 1, ;
		ColumnCount = (Alen(Thisform.arrItems,2)), ;
		RowSourceType = 5, ;
		RowSource = "thisform.arrItems", ;
		Style = 2, ;
		Top = 10, ;
		Width = 150, ;
		BoundTo = .T.
		
	Add Object smSearch as Textbox with top=50, left = 10
	
	Procedure smSearch.LostFocus
		Local lcSearch, lnRow
		lcSearch = Trim(this.Value)
		
		lnRow = Ascan(thisform.arrItems, m.lcSearch, 1, -1, 1, 1+8)
		If m.lnRow > 0 and !thisform.arrItems[m.lnRow,5]
			thisform.cmbSample.ListIndex = m.lnRow
		Else 
			thisform.cmbSample.ListIndex = 0
		endif
	endproc	

	Procedure Load
		Select Cust_id, Company, Contact, Country, Country='USA' As disableThis ;
			from (_samples+'data\customer') ;
			into Array This.arrItems
		Local ix
		For ix=1 to aLen(this.arrItems,1)
			If this.arrItems[m.ix,5]
				this.arrItems[m.ix,1]='\'+this.arrItems[m.ix,1]
				endif
		endfor
	Endproc

	Procedure Init
		This.cmbSample.NumberOfElements = Alen(This.arrItems)
	Endproc
Enddefine
>Hi, Cetin!
>
>I am populating the combo box via a method I wrote for the subclass that populates it from a two-dimensional array, one column the DisplayValue the other the Value (key to match to linked data).
>
>If I leave inactives out then I have to come up with some scheme to populate a visual control when older data wants to link to a value that is no longer in the list (once was active, now is inactive). This is not desirable, IMO.
>
>How do you go about displaying data for older records and yet try to make sure inactive data is not used on new records? I have been at this a couple of decades and the answer to that question is never easy. Either you need to replicate all data down to the detail level (so that deactivating lookup data does not change reports when run against old data) or you need to have some sort of versioning on all lookup data to know what to link to. This is why we never delete lookup data, we just mark it inactive. But then we still have this quandary of needing to keep it in the list for display purposes in a list that is also used to set the value for new records. I am getting tired of having to switch between a combo and textbox in order to display data in the two different scenarios, and if I could simply tell what is disabled I would pretty much have the best of both worlds.
>
>I suppose I could simply write code in the Valid or LostFocus to not allow selection of an inactive list item, but I am all ears as far as what other schemes people use in this scenario, whether that be an interface solution or a better way of data modeling all this.
>
>One final idea would be to clear and change all values in the combo box depending on whether the screen is in view or add/edit mode. Then inactive items are not cluttering up the list. These lists of lookup values are generally fairly small, but I do worry about performance with rebuilding the list depending on mode. Could also do the whole, "If I don;t find it in the list, add it," then remove it later, I suppose. Nothing feels elegant, though.
>
>Thanks,
>Joe Kaufman
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform