Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Listbox programmatically select & highlight
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01515590
Message ID:
01516395
Vues:
81
>I have a listbox.
>
>I want to preselect items in the listbox in the Init method of my form. the MultiSelect property is .T.
>
>I populate the listbox with a cursor, and then set individual Selected(i) = .T., for one or more entries.
>
>This appears to actually cause those items to be selected, but the selections lack the blue highlighting.
>
>When the user then clicks on items, the items clicked on do highlight.
>
>How do I get the programmatically selected items to appear highlighted.
>
>Thanks,
>Jim

Jim,

I think it might be an issue in your subclass or any other code? It works fine for me when I use base objects:
loForm		= CREATEOBJECT('form1')
loForm.show()
READ events

DEFINE CLASS form1 AS form


	Top = 0
	Left = 0
	Height = 265
	Width = 375
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT list1 AS listbox WITH ;
		Anchor = 15, ;
		ColumnWidths = "100", ;
		Height = 228, ;
		Left = 11, ;
		MultiSelect = .T., ;
		Top = 2, ;
		Width = 349, ;
		Name = "List1"


	ADD OBJECT text1 AS textbox WITH ;
		Height = 23, ;
		Left = 132, ;
		Top = 236, ;
		Width = 100, ;
		Name = "Text1"


	PROCEDURE Init
		this.List1.Selected(1)		= .t.
		this.List1.Selected(3)		= .t.
		this.List1.Selected(5)		= .t.
		this.text1.SetFocus()
	ENDPROC


	PROCEDURE Load
		CREATE CURSOR C_Countries (PK I AutoInc, Name C(20), MAP C(120))


		INSERT INTO C_Countries ( Name, Map ) VALUES ('France', HOME(4) + 'Icons\Flags\CTRFRAN.ICO')
		INSERT INTO C_Countries ( Name, Map ) VALUES ('Canada', HOME(4) + 'Icons\Flags\CTRCAN.ICO')
		INSERT INTO C_Countries ( Name, Map ) VALUES ('Germany', HOME(4) + 'Icons\Flags\CTRGERM.ICO')
		INSERT INTO C_Countries ( Name, Map ) VALUES ('Italy', HOME(4) + 'Icons\Flags\CTRITALY.ICO')
		INSERT INTO C_Countries ( Name, Map ) VALUES ('Japan', HOME(4) + 'Icons\Flags\CTRJAPAN.ICO')
		INSERT INTO C_Countries ( Name, Map ) VALUES ('Mexico', HOME(4) + 'Icons\Flags\CTRMEX.ICO')
		INSERT INTO C_Countries ( Name, Map ) VALUES ('Spain', HOME(4) + 'Icons\Flags\CTRSPAIN.ICO')
	ENDPROC


	PROCEDURE list1.Init
		LOCAL lnItem

		SELECT C_Countries

		SCAN
			this.AddListItem(ALLTRIM(C_Countries.Name), C_Countries.PK)
		ENDSCAN
	ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform