Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Bernard Bout
  Where is Bernard Bout?
 Brisbane
 Australia
 Bernard Bout
 To: Plutarco Roman
  Where is Plutarco Roman?
 USA
 Florida - United States
 Plutarco Roman
 Tags
Subject: RE: Combobox error when bound to object
Thread ID: 143251 Message ID: 143594 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 Category: .NET
Date: Thursday, August 30, 2007 6:10:58 AM         
   


What has this to do with .NET?

Please take more care and post in the correct categories.

> I created a simple class to work as a Business Object, works fine when bound to text boxes, but combo boxes will not show the .displayName when the value is changed by the user. Here is a piece of code that reproduces the behavior (pls cut and save as a prg to run).
> Im using vfp9 sp2 on Win XP.
>
> **** BOF *********
> * SOME DATA FOR THE TEST
> IF NOT FILE("somedata1.dbf")
> 	CREATE TABLE somedata1 (codigo i, nombre c(50))
> 	INSERT INTO somedata1 values(1,"CHINA")
> 	INSERT INTO somedata1 values(2,"USA")
> 	INSERT INTO somedata1 values(3,"AFRICA")	
> 	INSERT INTO somedata1 values(4,"UE")
> ELSE
> 	IF NOT USED("SOMEDATA1")
> 		USE someData1 IN 0
> 	ENDIF 
> ENDIF 
> IF NOT FILE("somedata2.dbf")
> 	CREATE TABLE somedata2 (codigo i, nombre c(50))
> 	INSERT INTO somedata2 values(1,"PI√ĎA")
> 	INSERT INTO somedata2 values(2,"NARANJA")
> 	INSERT INTO somedata2 values(3,"UVA")	
> 	INSERT INTO somedata2 values(4,"MANZANA")
> ELSE 
> 	IF NOT USED("SOMEDATA2")
> 		USE someData2 IN 0
> 	ENDIF 
> ENDIF 
> 
> IF NOT USED("mycursor")
> 	SELECT 0
> 	CREATE cursor mycursor (codigo i)
> 	SELECT mycursor
> 	APPEND BLANK 
> ENDIF 
> 
> * FORM 4 THE TEST
> PUBLIC  oForm as Form 
> oForm = CREATEOBJECT("myForm")
> oform.show
> 
> ** CLASSES USED
> *  - Form
> DEFINE CLASS myForm as Form 
> 	Visible = .t.
> 	
> 	PROCEDURE load 
> 		LOCAL o1 as ComboBox, l1 as Label
> 		PUBLIC bo2 as clsBo 
> 		
> 		bo2 = CREATEOBJECT("clsBo")
> 		
> 		this.AddObject("bo1","clsBo")
> 
> 		this.AddObject("label1","label")
> 		l1 = this.label1
> 		l1.top 		= 71
> 		l1.Caption 	= "Bound to object"
> 		l1.Visible 	= .t.
> 
> 		this.AddObject("label2","label")
> 		l1 = this.label2
> 		l1.top 		= 100
> 		l1.Caption 	= "Bound to cursor"
> 		l1.Visible 	= .t.
> 
> 		this.AddObject("label3","label")
> 		l1 = this.label3
> 		l1.top 		= 130
> 		l1.Caption 	= "Bound public obj"
> 		l1.Visible 	= .t.
> 
> 		this.addObject("combo1","combobox")
> 		o1 				= this.combo1
> 		o1.BoundColumn	= 2
> 		o1.BoundTo 		= .t.
> 		o1.RowSource	= "somedata1.nombre,codigo"
> 		o1.ControlSource= "thisform.bo1.codigo"
> 		o1.Height 		= 24
> 		o1.left 		= 100
> 		o1.width 		= 216
> 		o1.Style 		= 2
> 		o1.Top			= 71
> 		o1.Visible 		= .t.
> 		o1.RowSourceType= 2 
> 
> 		this.addObject("combo2","combobox")
> 		o1 				= this.combo2
> 		o1.BoundColumn	= 2
> 		o1.BoundTo 		= .t.
> 		o1.RowSource	= "somedata2.nombre,codigo"
> 		o1.ControlSource= "mycursor.codigo"
> 		o1.Height 		= 24
> 		o1.left 		= 100
> 		o1.width 		= 216
> 		o1.Style 		= 2
> 		o1.Top			= 100
> 		o1.Visible 		= .t.
> 		o1.RowSourceType= 2 
> 		
> 		this.addObject("combo3","combobox")
> 		o1 				= this.combo3
> 		o1.BoundColumn	= 2
> 		o1.BoundTo 		= .t.
> 		o1.RowSource	= "somedata2.nombre,codigo"
> 		o1.ControlSource= "bo2.codigo"
> 		o1.Height 		= 24
> 		o1.left 		= 100
> 		o1.width 		= 216
> 		o1.Style 		= 2
> 		o1.Top			= 130
> 		o1.Visible 		= .t.
> 		o1.RowSourceType= 2 
> 
> 	ENDPROC 
> ENDDEFINE 
> 
> *  -Class as Business Object
> DEFINE CLASS clsBO as Custom 
> 	codigo = 2
> 	nombre = ""
> 	lError = .f.
> 	cError = ""
> 	
> 	procedure nombre_Assign
> 	LPARAMETERS s
> 		IF LEN(s) < 5
> 			this.nombre = ""
> 			this.seterror("NOMBRE DEBE SER MAYOR DE 5 LETRAS")
> 		ELSE
> 			this.nombre = s
> 			this.seterror()
> 		ENDIF 
> 	ENDPROC 
> 	
> 	PROCEDURE setError
> 	PARAMETERS s
> 		IF EMPTY(s)
> 			this.lError = .f.
> 			this.cError = ""
> 		ELSE
> 			this.lError = .t.
> 			this.cError = s
> 		ENDIF 
> 	ENDPROC 
> ENDDEFINE
> ***** EOF  ******
> 




Bernard

** If you see someone without a smile, give em one of yours :) **

ENTIRE THREAD

Combobox error when bound to object Posted by plutarco roman @ 8/26/2007 11:57:21 PM
RE: Combobox error when bound to object Posted by Cetin Basoz @ 8/27/2007 11:40:50 AM
RE: Combobox error when bound to object Posted by Bernard Bout @ 8/30/2007 6:10:58 AM