Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 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: 143266 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 Category: .NET
Date: Monday, August 27, 2007 11:40:50 AM         
   


* FORM 4 THE TEST
Public  oForm As Form
oForm = Createobject("myForm")
oForm.Show

** CLASSES USED
*  - Form
Define Class myForm As Form
  DataSession = 2

  Add Object bo1 As clsBo

  Add Object label1 As Label With top = 71, Caption = "Bound to object"
  Add Object combo1 As  ComboBox With ;
    Height = 24, Left = 100, Width = 216, Top = 71, ;
    BoundColumn	= 2, ;
    BoundTo = .T., ;
    RowSource	= "select nombre,codigo from somedata1 into cursor crsCombo1", ;
    ControlSource= "thisform.bo1.codigo", ;
    RowSourceType= 3, ;
    Style = 2

  Add Object label2 As Label With top = 100, Caption = "Bound to cursor"
  Add Object combo2 As ComboBox With ;
    Height = 24,Left = 100,Width = 216,Top = 100,;
    BoundColumn	= 2,;
    BoundTo = .T.,;
    RowSource	= "select nombre,codigo from somedata2 into cursor crsCombo2",;
    ControlSource= "mycursor.codigo",;
    Style = 2,;
    RowSourceType= 3

  Add Object label3 As Label With top = 130, Caption = "Bound public obj"
  Add Object combo3 As ComboBox With ;
    Height= 24,Left= 100,Width= 216,Top= 130,;
    BoundColumn	= 2,;
    BoundTo = .T.,;
    RowSource	= "select nombre,codigo from somedata2 into cursor crsCombo3",;
    ControlSource= "bo2.codigo",;
    Style = 2,;
    RowSourceType= 3

  Procedure Load
    Create Cursor 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")

    Create Cursor 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")


    Select 0
    Create Cursor mycursor (codigo i)
    Select mycursor
    Append Blank


    Public bo2 As clsBo
    bo2 = Createobject("clsBo")
  ENDPROC
enddefine

*  -Class as Business Object
Define Class clsBo As Custom
  codigo = 2
  nombre = ""
  lError = .F.
  cError = ""
  
  Procedure nombre_Assign
    Lparameters s
    If Len(m.s) < 5
      This.nombre = ""
      This.seterror("NOMBRE DEBE SER MAYOR DE 5 LETRAS")
    Else
      This.nombre = m.s
      This.seterror()
    Endif
  Endproc

  Procedure seterror
    Lparameters s
    If Empty(m.s)
      This.lError = .F.
      This.cError = ""
    Else
      This.lError = .T.
      This.cError = m.s
    Endif
  Endproc
Enddefine


PS: IMHO public bo2 is a bad idea.
Cetin Basoz

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