Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is this a BUG or I am missing something?
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Is this a BUG or I am missing something?
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01136872
Message ID:
01136872
Vues:
64
I tried to answer to a question in another forum. The question was how to use EditBox in Grid w/o using MemoField. The ma who asks has a function which returns some string. I suggested him to use this function as a control source (He don't want to use EditBox outside of grid, which was my first suggestion). The problem is that if Function returns more than 255 chars grid blows up. Try this code:
oForm = CREATEOBJECT([Form1])
oForm.Show()
READ EVENTS



DEFINE CLASS form1 AS Form


    Top = 0
    Left = 0
    Height = 728
    Width = 618
    DoCreate = .T.

    *** CHANGE this to be more that 21 and see what happens with grid
    defaultreplicate = 21


    ADD OBJECT grid1 AS grid WITH ;
        ColumnCount = 2, ;
        Height = 479, ;
        Left = 21, ;
        Panel = 1, ;
        RecordSource = "ctest", ;
        RowHeight = 72, ;
        Top = 247, ;
        Width = 595, ;
        Name = "Grid1", ;
        Column1.ControlSource = "ctest.Fld1", ;
        Column1.Name = "Column1", ;
        Column2.ControlSource = "(thisform.ReturnMyVar())", ;
        Column2.Width = 474, ;
        Column2.Sparse = .F., ;
        Column2.Name = "Column2"



    ADD OBJECT edit1 AS editbox WITH ;
        Height = 183, ;
        Left = 17, ;
        Top = 9, ;
        Width = 279, ;
        Name = "Edit1",;
        ControlSource = [(thisform.Returnmyvar(50))]


    ADD OBJECT command1 AS commandbutton WITH ;
        Top = 208, ;
        Left = 211, ;
        Height = 27, ;
        Width = 84, ;
        Caption = "Command1", ;
        Name = "Command1"


    PROCEDURE ReturnMyVar(nCount)
        nCount = IIF(VARTYPE(nCount) # [N], thisform.DefaultReplicate, nCount)
        o1 = SYS(2015)
        RETURN REPLICATE(o1+CHR(13)+CHR(10),nCount)
    ENDPROC


    PROCEDURE Load
        CREATE CURSOR cTest (fld1 I)
        FOR asd = 1 TO 20
            INSERT INTO cTest VALUES (asd)
        NEXT
        GO TOP
    ENDPROC

    PROCEDURE Init
        WITH thisform.Grid1.Column2
              .AddObject([Edit1],[EditBox])
              .removeObject([Text1])
              .CurrentControl = [Edit1]
              .ControlSource = "(thisform.ReturnMyVar())"
              .Sparse = .f.
              .Edit1.Visible = .t.
        ENDWITH
    ENDPROC 

    PROCEDURE command1.Click
        thisform.Edit1.Refresh()
    ENDPROC

    PROCEDURE Destroy
        CLEAR EVENTS
    ENDPROC

ENDDEFINE
If ReturnMyVar method returns more than 255 chars grid doesn't shows at all or if it shows when yuo click in column with EditBox BOMBS with "String is too long to fit", but the EditBox which is outside grid has no problems at all.
I consider this as a BUG, but maybe I missed something.

(Naomi, I made my test. You were right, I can't change the title ;-) )
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform