Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combo in grid
Message
From
30/04/1998 08:54:45
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Miscellaneous
Thread ID:
00091202
Message ID:
00095947
Views:
34
>>Mark,
>>
>>I have a question related to Valentin's combo in grid.
>>
>>What if I want the combo box use different cursors which depends on the data in other column?
>>
>>For example, I have 2 columns of grid, item, supplier. The supplier column is a combo box. When item has default supplier(s), the suppliers' id should be shown in combo box. If item doesn't have default supplier, the combo box should be filled with vendor id.
>>
>>Please take it slow, if you will.
>>
>I do not understand why you use a combo box for the supplier/vendor because it looks to me this is a value that you would not allow your users to change. The value is based on the actual item.
>
>Regardless, in a grid, what you are wanting to do could be a problem because the grid displays multiple records that have different values for the item and supplier/vendor. You can only do this with a relation between the item + supplier tables and item + vendor tables. This could probably be done with a parameterized view, and I am almost certain it will require a SQL Union among other things. I am going to place a little faith in more seasoned members here on the UT to hopefully help with this. I suggest you post a new thread with this specific question including details about the tables and example field names involved.
Below is a class that I use. It allows default values be choosen and when needed new values be entered (uses SQL).
**************************************************
*-- Class:        mycombo_edit (c:\temp\test.vcx)
*-- ParentClass:  combobox
*-- BaseClass:    combobox
*
DEFINE CLASS mycombo_edit AS combobox


	Height = 22
	Width = 100
	DisabledBackColor = RGB(255,255,255)
	aliasname = "None"
	fieldname = "None"
	Name = "mycombo_edit"


	PROCEDURE When
		THIS.REQUERY
	ENDPROC


	PROCEDURE LostFocus
		this.value = this.displayvalue
	ENDPROC


	PROCEDURE Init
		WITH This
			.rowsourcetype = 3
			if lower(.fieldname)="none" or ;
				lower(.aliasname)="none"
				.fieldname = substr(.controlsource,rat(".",.controlsource)+1)
				.aliasname = substr(.controlsource,1,;
								rat(".",.controlsource)-1)
			endif
			.rowsource = [SELECT DISTINCT ]+THIS.fieldname +;
				[ as dummy FROM ]+this.aliasname+[ where !empty(]+THIS.fieldname + ;
				[) union ] +;
				[SELECT this.displayvalue as dummy ] +;
				[ FROM ]+this.aliasname + ;
				[ INTO cursor qq order by 1 ]
		ENDWITH
	ENDPROC

ENDDEFINE
*
*-- EndDefine: mycombo_edit
**************************************************
When controlsource is bound to main table and aliasname, fieldname point to lookup table, it provides a way to add new entries just to main table. Of course some code in item lostfocus (or valid, interactivechange, programmaticchange) would be needed to get corresponding supplier if any.
Cetin
Ç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
Previous
Reply
Map
View

Click here to load this message in the networking platform