Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Incremental search
Message
 
 
To
05/06/2001 15:15:51
Ing. T.R.M. Pluym
Pluym Elektronics Bv
Hulst, Netherlands
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00514814
Message ID:
00515381
Views:
23
>I downloaded the Ingrid DEMO and it works just fine, just what i have been looking for.
>
>But because i'm new to Foxpro i can't figure out how to handle:
>
>- Add the InGrid control to each grid column (the advantage of this
> is that each column can be setup to search on a different tag -
> the disadvantage is the extra work) to utilize the incremental
> search capabilities.
>
>- Set the InGrid controls as the active controls in each column.
>
>Can i do this whitin the Foxpro interface or do i have to handle this manual ?

Hi Ing,

I think, it might be handled with builders, but I have to admit, I've never created builders before, so I do it either in design-time or in run-time programmatically. This is FormatAndSetCaption method of our grid, which does that. It could be called from grid.Init or form.init:
********************************************************************
*  Description.......: TMwgGrid.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 05/29/2001 02:33:49 PM
********************************************************************
local loColumn, loControl, lnWidthTotal, lnSel,  ;
     lnFWidth, lnCWidth, lcFieldName, lcFieldType, lcCaption, lcTestName
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
               if !empty(set('database'))
                    lcCaption=dbgetprop(m.lcTestName,'field','caption')
               endif
               if empty(m.lcCaption)  && There is no DBC caption, Just use the Field name
                    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 
               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' && 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
Here you can see, I replace the original textbox with InGrid class. Note, that if you have any methods in Text boxes, they would be lost now. I have a property in my grid lIncremental, which if set to true, means, I want to replace.

In this sample you also would notice, that I replace each header with myHeader class. MyHeader class has only one feature - it allows sort grid by dblClick on it (In Cetin's classes he uses single click, but it's a lot extra work).

I would also recommend you to take a look at Cetin's FoxyClasses and play with the demo.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform