Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Listbox programmatically select & highlight
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01515590
Message ID:
01516558
Views:
106
>>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
>**************************************************
>
Hugo,

Thanks for your suggestions.

I originally had derived my listboxclass from _listbox, a VFP FFC class. So, I changed that just now to derive directly from listbox. No change.

I will try to replicate what you show here and see how that works. Right now, I am populating the grid from a cursor (RowSourceType = 2-Alias).

I will let you know if I make any progress on this.

Jim
Previous
Reply
Map
View

Click here to load this message in the networking platform