Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is this a BUG or I am missing something?
Message
From
17/07/2006 17:29:08
 
 
To
17/07/2006 04:40:45
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01136872
Message ID:
01137066
Views:
32
This message has been marked as the solution to the initial question of the thread.
>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 ;-) )

None bug, but your code is wrong.

The column uses internal textbox routines,
and it's controlsource is bounded to 255 chars.

The correct code is this:
oForm = CREATEOBJECT([Form1])
oForm.Show()
READ EVENTS



DEFINE CLASS form1 AS Form


    Height = 728
    Width = 618

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


    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.Bound = .F., ;  && unlink column and cell
        Column2.ControlSource = "", ; && the error is here
        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)
        RETURN REPLICATE(SYS(2015)+CHR(13)+CHR(10),IIF(VARTYPE(nCount) # [N], thisform.DefaultReplicate, 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
        	 .removeObject([Text1])
              .AddObject([Edit1],[EditBox])
              .CurrentControl = [Edit1]
              * attention here
              .Edit1.ControlSource = "(thisform.ReturnMyVar())"
              .Edit1.Visible = .t.
        ENDWITH
    ENDPROC 

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

    PROCEDURE Destroy
        CLEAR EVENTS
    ENDPROC

ENDDEFINE
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform