Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combobox behavior using DropDown event
Message
From
01/10/2004 10:37:32
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Combobox behavior using DropDown event
Miscellaneous
Thread ID:
00947940
Message ID:
00947940
Views:
69
Hi all,

Based on VFP help, I can use the DropDown event of a Combobox to update the list dynamically before presenting it to the user. However, there seems to be some weird behavior going on. Using the code snippet below do the following to test:
1. Run the program.
2. Click on the combobox Down Arrow to display a list of 3 items.
3. Click on the optiongroup Option 1 option.
4. Click on the combobox Down Arrow and a list is displayed with three lines
including an empty line.
5. Click on the optiongroup Option 2 option.
6. Click on the combobox Down Arrow and a two-line list is displayed with
a scroll button.

You can mix and match click/dropdown to see different kinds of behavior. What I
was hoping for is that for the combobox to adjust the dropdown list properly -
meaning - a list with three lines if there are three items or a list of two lines if there are two items.

Or maybe my implementation is incorrect.
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


	**************************************************
*-- Form:         form1 (d:\test\test combobox.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   10/01/04 10:25:12 AM
*
DEFINE CLASS form1 AS form


	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT combo1 AS combobox WITH ;
		ColumnCount = 2, ;
		ColumnWidths = "100,200", ;
		Height = 24, ;
		Left = 192, ;
		Top = 72, ;
		Width = 100, ;
		Name = "Combo1"


	ADD OBJECT optiongroup1 AS optiongroup WITH ;
		ButtonCount = 2, ;
		Value = 2, ;
		Height = 46, ;
		Left = 24, ;
		Top = 72, ;
		Width = 132, ;
		Name = "Optiongroup1", ;
		Option1.Caption = "Option1", ;
		Option1.Value = 0, ;
		Option1.Height = 17, ;
		Option1.Left = 5, ;
		Option1.Top = 5, ;
		Option1.Width = 61, ;
		Option1.Name = "Option1", ;
		Option2.Caption = "Option2", ;
		Option2.Value = 1, ;
		Option2.Height = 17, ;
		Option2.Left = 5, ;
		Option2.Top = 24, ;
		Option2.Width = 61, ;
		Option2.Name = "Option2"


	PROCEDURE Init
		create cursor test (f1 i, f2 c(10))
		insert into test values (1, "Hello")
		insert into test values (1, "World")
		insert into test values (2, "How")
		insert into test values (2, "are")
		insert into test values (2, "you?")
	ENDPROC


	PROCEDURE combo1.DropDown
		this.RowSourceType = 0
		this.Clear()
		this.RowSourceType = 3 
		this.RowSource = ;
			"select * from test where f1=" + ;
			transform(thisform.optiongroup1.Value) + ;
			" into cursor cxxx"
		this.Requery()
	ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
ramil
~~ learning to stand still
Next
Reply
Map
View

Click here to load this message in the networking platform