Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GRID - DynamicCurrentControl - Is there a limit?
Message
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00562699
Message ID:
00562740
Views:
31
>>>What about:
>>>DynamicCurrentControl='myTable.Nome_Object'. It should work just fine.
>>
>>>I aslo agree with Keith's suggestion, but you should make changes in >AfterRowColChange. At least, this is how it works for ReadOnly property.
>>
>> Thanks, but i will try to explain my problem better. I need to have an edition grid where a column has different objects in each line, these objects are linked to different fields from other table.
>>
>> I am creating on-line an object container and adding a Combobox, Textbox, checkbox and etc..., depending on the type of the field to be attributed in ControlSource.
>>
>>Regards
>
>Are you sure, you want to have this headache? Containers in Grid make grid very messy. Anyway, judging by the expression, you used, you can either have a field in a table called CurControl, or a global variable (or form's property). This field (variable, property) would hold the DynamicCurrentControl for this record (that's why Table approach is preferable, if Sparse=.f.), and your DynamicCurrentControl would be just myTable.CurControl or thisform.curControl.
>
>Otherwise I would place your container on form instead of messing with grid.

After re-reading your message, I think, you meant Dynamic Grid Creation rather than puting container in Grid. If yes, see Vlad's articles in UT magazine and this code, that might be helpful:
********************************************************************
*  Description.......: NNwgGrid.FormatAndSetCaption - format all grid columns and set caption to be in Proper format
*  Calling Samples...:
*  Parameter List....:
*  Created by........: Nadya Nosonovsky 03/09/2000 02:03:22 PM
*  Modified by.......: Nadya Nosonovsky 09/19/2001 12:31:13 PM
********************************************************************
local loColumn, loControl, lnWidthTotal, lnSel,  ;
     lnFWidth, lnCWidth, lcFieldName, lcFieldType, lcCaption, lcTestName, lcDBC
lnSel=select() && save current area
with this
     if .recordsourcetype = 1 or .recordsourcetype = 0 && Alias or table
          select (.recordsource)
          lnWidthTotal= iif(.recordmark, 10,0)+ iif(.scrollbars>1,sysmetric(5),0) ;
               + 2 * .gridlinewidth + iif(.deletemark, 10,0)+10 && record marker & vertical scroll bar+deletion mark
          for each loColumn in .columns
* -- For each column determine the width and use the correct caption.
* -- Display the caption via the proper() function.
               lcFieldName=justext(loColumn.controlsource)
               lcTestName=lower(juststem(dbf(alias()))+"."+m.lcFieldName)
               lcFieldType=type(m.lcFieldName)
               lnFWidth=iif(m.lcFieldType='D',13,iif(m.lcFieldType='T',28,fsize(m.lcFieldName)+3)) && Field size
               lcDBC = set('database')
               if !empty(m.lcDBC) and juststem(cursorgetprop('Database',.recordsource)) = m.lcDBC
                    lcCaption=dbgetprop(m.lcTestName,'field','caption')               
                   if empty(m.lcCaption)  && There is no DBC caption, Just use the Field name
                        lcCaption=proper(m.lcFieldName)
                   endif
              else
                   lcCaption=proper(m.lcFieldName)
              endif
               loColumn.removeobject('Header1')
               loColumn.newobject('Header1','MyHeader','MyHeader.prg',,m.lcCaption) && custom header
               lnCWidth=(txtwidth(loColumn.Header1.caption,loColumn.Header1.fontname,loColumn.Header1.fontsize)+2) * ;
                    fontmetric(6,loColumn.Header1.fontname,loColumn.Header1.fontsize)+3 && Width of caption
               loColumn.width=round(max(m.lnFWidth*fontmetric(6,loColumn.fontname,loColumn.fontsize),m.lnCWidth),0)
               lnWidthTotal=m.lnWidthTotal+loColumn.width

** Nadya Nosonovsky 03/29/2000 01:35:47 PM added Incremental Search (could be added for ReadOnly grid)

               if .lIncremental and m.lcFieldType='C' && We would use this feature only for char fields
                    if lower(loColumn.currentcontrol)='text1' && standard text1 control
                         loColumn.removeobject('text1')
                         if lower(m.lcFieldName)='code' and ;
                             (candidate(tagno('code')) or primary(tagno('code'))) && should be unique
                              loColumn.newobject('text1','nnIngrid','fields_controls.vcx') && Incremental search textbox
                              thisform.lCheck=.t. && Code value should be unique
                              loColumn.text1.pcFields='code'
                              loColumn.text1.pcValidTag='code'
                              loColumn.text1.cSeekTag='code'
                         else
                              loColumn.newobject('text1','ingrid','wgcontrols.vcx') && Incremental search textbox
                              loColumn.text1.cLocateExpression='upper('+m.lcFieldName+')'
                         endif
                         loColumn.text1.visible=.t.
                    endif
               endif

*  Nadya Nosonovsky 03/29/2000 01:36:17 PM added Show Memo
               if .lShowMemo and m.lcFieldType='M' && We want to show Memo field
                    if lower(loColumn.currentcontrol)='text1' && standard text1 control
                         loColumn.removeobject('text1')
                         loColumn.newobject('text1','edtexpand','wgcontrols.vcx') && expandable editbox
                         loColumn.text1.visible=.t.
                         loColumn.sparse=.f.
                    endif
               endif
          endfor
          .width=min(.width,m.lnWidthTotal)
     endif
endwith
select (m.lnSel) && return to previous area
You may add a check for the field type in this code and remove textbox and use your control here.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform