Local CCURRDIR
CCURRDIR = Set("DIRECTORY")

Cd (Justpath(Substr(Sys(16),Iif(Sys(16)="PROCEDURE",At(" ",Sys(16),2),1))))
Local LCCURRPROC
LCCURRPROC = Set("PROCEDURE")
* ******************************************************
* * Auteur              :Eddy Maue
* * -----------------------------
CreateTable()
* ******************************************************

Public oFrm As Form
oFrm = Createobject("FrmGrdsCbo")
oFrm.AutoCenter = .T.
oFrm.AlwaysOnTop = .T.
oFrm.Show(1)
Cd (CCURRDIR)

* ******************************************************
* * Auteur              :Eddy Maue
* * -----------------------------
* * Classe Nom          :FrmGrdsCbo
* * Classe Parent       :Form
* * -----------------------------
* * Créé le             :04/19/06
* * Modifier le         :
* ******************************************************
Define Class  FrmGrdsCbo As Form

    f10 =""
    Add Object Grid1 As Mygrid With Left = 10

    * ******************************************************
    * * FrmGrdsCbo :: Init
    * ******************************************************
    * * Créé le             :04/19/06
    * * Modifier le         :
    * ******************************************************
    Procedure Init
    	MESSAGEBOX("Faites F10 pour ajouter un enregistrement",0+64)
        This.f10 = On("key","f10")
        On Key Label f10 Append Blank
        Thisform.Width = 20 + This.Grid1.Width
        SELECT ("friends")
    Endproc && FrmGrdsCbo :: Init

    * ******************************************************
    * * FrmGrdsCbo :: Destroy
    * ******************************************************
    * * Créé le             :04/19/06
    * * Modifier le         :
    * ******************************************************
    Procedure Destroy
    
        doit = [ON KEY LABEL F10 ]+ This.f10
        Release oFrm

    Endproc && FrmGrdsCbo :: Destroy

    * ******************************************************
    * * FrmGrdsCbo :: Error
    * ******************************************************
    * * Créé le             :04/19/06
    * * Modifier le         :
    * ******************************************************
    Procedure Error(nError, cMethod, nLine)

    Endproc && FrmGrdsCbo :: Error

Enddefine

* ******************************************************
* * Auteur              :Eddy Maue
* * -----------------------------
* * Classe Nom          :MyGrid
* * Classe Parent       :Grid
* * -----------------------------
* * Créé le             :04/19/06
* * Modifier le         :
* ******************************************************
Define Class  Mygrid As Grid
    Height = 200
    Width = 448
    RowHeight = 18
    RecordSource = "Friends"

    Add Object column1 As MyColTxt With ;
        ControlSource = "Friends.Name" ,;
        width = 152

    Add Object column2 As MyColTxt With ;
        ControlSource = "Friends.Address" ,;
        Width = 166

    Add Object column3 As MyColCbo With ;
        ControlSource = "Friends.State" ,;
        Bound = .F. ,;
        Width = 93

    * ******************************************************
    * * Column3.Combox1
    * ******************************************************
    **  Créé par            : Eddy Maue
    * * Créé le             : 04/19/06
    * * Modifier le         :
    * ******************************************************
    Procedure column3.ComboBox1.Init
        With This
            .BoundColumn = 2
            .ColumnCount = 2
            .ColumnWidths = "75,0"
            .ControlSource = "Friends.State"
            .RowSourceType = 6	&& -Fields
            .RowSource = "States.FullName,Abbrev"
            .Style = 2 			&& - DropDown List
        Endwith
    Endproc && Column3.Combox1


    * ******************************************************
    * * Column3.combox.gotfocus
    * ******************************************************
    **  Créé par            : Eddy Maue
    * * Créé le             : 04/19/06
    * * Modifier le         :
    * ******************************************************
    Procedure column3.ComboBox1.GotFocus
        If !Empty(Friends.State)
            This.Value = Friends.State
        Else
            This.DisplayValue = This.List(1)
        Endif
        ** This lets you see the current state value in the combo box
        ** or if it is a new record it displays the first state in the list.

    Endproc && Column3.combox.gotfocus


    * ******************************************************
    * * MyGrid :: Init
    * ******************************************************
    * * Créé le             :04/19/06
    * * Modifier le         :
    * ******************************************************
    Procedure Init

    Endproc && MyGrid :: Init

    * ******************************************************
    * * MyGrid :: Destroy
    * ******************************************************
    * * Créé le             :04/19/06
    * * Modifier le         :
    * ******************************************************
    Procedure Destroy

    Endproc && MyGrid :: Destroy

    * ******************************************************
    * * MyGrid :: Error
    * ******************************************************
    * * Créé le             :04/19/06
    * * Modifier le         :
    * ******************************************************
    Procedure Error(nError, cMethod, nLine)

    Endproc && MyGrid :: Error

Enddefine

* ******************************************************
* * Auteur              :Eddy Maue
* * -----------------------------
* * Classe Nom          :MyColCbo
* * Classe Parent       :MyColumn
* * -----------------------------
* * Créé le             :04/19/06
* * Modifier le         :
* ******************************************************
Define Class  MyColCbo As MyCol
    Add Object ComboBox1 As MyComboBox
    * ******************************************************
    * * MyColCbo :: Init
    * ******************************************************
    * * Créé le             :04/19/06
    * * Modifier le         :
    * ******************************************************
    Procedure Init

    Endproc && MyColCbo :: Init
Enddefine

* ******************************************************
* * Auteur              :Eddy Maue
* * -----------------------------
* * Classe Nom          :MyColTxt
* * Classe Parent       :MyCol
* * -----------------------------
* * Créé le             :04/19/06
* * Modifier le         :
* ******************************************************
Define Class  MyColTxt As MyCol

    Add Object TextBox1 As MyTextBox
    * ******************************************************
    * * MyColTxt :: Init
    * ******************************************************
    * * Créé le             :04/19/06
    * * Modifier le         :
    * ******************************************************
    Procedure Init

    Endproc && MyColTxt :: Init
Enddefine


* ******************************************************
* * Auteur              :Eddy Maue
* * -----------------------------
* * Classe Nom          :MyCol
* * Classe Parent       :Custom
* * -----------------------------
* * Créé le             :04/19/06
* * Modifier le         :
* ******************************************************
Define Class  MyCol As Column

    * ******************************************************
    * * MyCol :: Init
    * ******************************************************
    * * Créé le             :04/19/06
    * * Modifier le         :
    * ******************************************************
    Procedure Init

    Endproc && MyCol :: Init

Enddefine

* ******************************************************
* * Auteur              :Eddy Maue
* * -----------------------------
* * Classe Nom          :MyTextBox
* * Classe Parent       :textbox
* * -----------------------------
* * Créé le             :04/19/06
* * Modifier le         :
* ******************************************************
Define Class  MyTextBox As TextBox

    * ******************************************************
    * * MyTextBox :: Init
    * ******************************************************
    * * Créé le             :04/19/06
    * * Modifier le         :
    * ******************************************************
    Procedure Init

    Endproc && MyTextBox :: Init


Enddefine

* ******************************************************
* * Auteur              :Eddy Maue
* * -----------------------------
* * Classe Nom          :MyCombo
* * Classe Parent       :Custom
* * -----------------------------
* * Créé le             :04/19/06
* * Modifier le         :
* ******************************************************
Define Class  MyComboBox As ComboBox

    * ******************************************************
    * * MyCombo :: Init
    * ******************************************************
    * * Créé le             :04/19/06
    * * Modifier le         :
    * ******************************************************
    Procedure Init

    Endproc && MyCombo :: Init


Enddefine




* ******************************************************
* * Auteur              :Eddy Maue
* * -----------------------------
* * Créé le             :04/19/06
* * Modifier le         :
* ******************************************************
Procedure CreateTable()
    =UseTable("States")
    =UseTable("Friends")
Endproc

Procedure UseTable(cTable)

    If !Used(cTable)
        If !File(cTable+".dbf")
            Do Case
                Case cTable=States
                    * creer votre table ici
                    Create Table States (FullName C(20), Abbrev C(2))
                    Insert Into States Values ("Alaska","AK")
                    Insert Into States Values ("Colorado","CO")
                    Insert Into States Values ("Florida","FL")
                    Insert Into States Values ("Idaho","ID")
                    Insert Into States Values ("Maine","ME")
                    Insert Into States Values ("Ohio","OH")
                    Insert Into States Values ("Texas","TX")
                    *--------------------------------
                Case cTable=Friends
                    * creer votre table ici
                    Create Table Friends (Name C(40), Address C(30), State C(2))

                    *--------------------------------
            Endcase
        Else
            Use (cTables) In 0
        Endif
    Endif

    Return Select(cTable)

Endproc

