Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Memo Field in a Grid
Message
From
16/10/2001 10:54:21
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00568983
Message ID:
00569035
Views:
43
>>>
>>>You are absolutely correct, it is the default action. Hrm. Is there a SET command that will turn that off? I created a completely new grid on my form, and ran the program, and the double click doesn't work. But it worked fine on my test form that was outside of the program. I must have some SET command turned on or off that disables the double clicking on Memo fields.
>>>
>>>Any ideas?
>>>
>>>Thanks!
>>
>>I don't know of a set command that would disable it. Grid might be a subclassed grid with code controlling it or something like a container in front of it ?
>>Also Ctrl+Home, Ctrl+PgDown or Up open memo window (only set command comes to mind is 'set window of memo to ...'
>>Cetin
>
>Cripes. It's not working because the form the grid is on is MODAL. therefore, it can't spawn the window to view the memo...
>
>So I've got this *completely* standard grid on a modal form. Just plopped on a grid from from the toolbox onto the form and didn't change any properties or methods. Is there a way to have EVERY column that is generated at runtime by that grid (which will display the current ALIAS()) run the exact same code on the double click event?
>
>What I want to do is
>
>IF TYPE(This.ControlSource)="M"
> DO FORM VIEWMEMO
>ENDIF
>
>(where ViewMemo is a modal form with an edit box on it, that will do nothing but show the data in the memo field). Is there any way to do this?

Yes. Download 'Two grid classes' from download area. One is multiselectgrid. Checking its code you can easily adopt your code. Or for a pure .prg version of building grids on the fly you can check this (assumed testdata.dbc is in current dir):
Use products in 0
Use employee in 0
oForm  = createobject('myForm')
With oForm
  .Addobject('myGrid','myGrid')
  .Addobject('myButton','myButton')
  .MyButton.visible = .t.
  With .myGrid
    .Top=oForm.MyButton.Height + 10
    .Left = 10
    .Height = oForm.Height - (.Top+20)
    .Width = oForm.Width - 20
    .SetSource('products')
    .Visible = .t.
  Endwith
  .Show
Endwith
Read events

Define class myForm as Form
  Height = 400
  Width = 600
  ShowTips = .T.
  Procedure SampleShortCut
  Lparameters oTarget
Define POPUP shortcut shortcut RELATIVE FROM MROW(),MCOL()
Define BAR _MED_CUT OF shortcut PROMPT "\&ltCut"
Define BAR _MED_COPY OF shortcut PROMPT "C\&ltopy"
Define BAR _MED_PASTE OF shortcut PROMPT "\&ltPaste"
Define BAR 4 OF shortcut PROMPT "Copy Object value"
Define BAR 5 OF shortcut PROMPT "Change column color"
On SELECTION BAR 4 OF shortcut _cliptext = oTarget.Value && Alternative copy
On SELECTION BAR 5 OF shortcut oTarget.SwitchColor()
Activate POPUP shortcut
Endproc

  Procedure queryunload
  Clear events
Endproc
Enddefine

Define class MyButton as CommandButton
  Caption = 'Switch source'
  Procedure click
  With thisform.myGrid
    .SetSource(iif(upper(.Recordsource)='EMPLOYEE','products','employee'))
  Endwith
Endproc
Enddefine

Define class myGrid as grid
  DeleteMark = .F.
  ReadOnly = .T.
  RecordMark = .F.
  ScrollBars = 3
  SplitBar = .F.
  Highlight = .F.
  HighlightRow = .F.
  Name = "grdMyGrid"
  FreeTable = .t.

  Procedure addcolumn
  Lparameters nIndex, cAlias, cField, cCaption
  Nodefault
  This.addobject("clm"+cField,"myColumn", cAlias+"."+cField,nIndex)
Endproc

  Procedure SetSource
  Lparameters tcRecordsource
  With this
    .recordsource = ''
    .Columncount = -1
    .recordsource = tcRecordsource
    .FreeTable = empty(cursorgetprop("Database",tcRecordsource))
    If !.FreeTable
      Open database (cursorgetprop("Database",tcRecordsource))
    Endif
    nOldColCount = .columncount
    For ix = 1 to fcount(tcRecordsource)
      .AddColumn(ix, tcRecordsource,field(ix,tcRecordsource))
    Endfor
    For ix = nOldColCount to 1 step -1
      .RemoveObject(.Columns(ix).name)
    Endfor
    .SetAll('Visible',.t.)
  Endwith
Endproc
Enddefine

Define class myColumn as column
  Resizable = .F.
  Movable = .F.
  Procedure init
  Lparameters cControlSource, nIndex
  With this
    .controlsource = cControlSource
    .ColumnOrder = nIndex
    .RemoveObject('Header1')
    .Addobject('myHeader','myHeader')
    If type(cControlSource)='L'
      .AddObject("myControl","myGridChkBox")
    Else
      .AddObject("myControl","myGridTxtBox")
    Endif
    .CurrentControl = "myControl"
    .Sparse = .F.
  Endwith
Endproc
  Procedure resize
  This.myControl.Resize
Endproc

  Procedure MouseMove
  Lparameters nButton, nShift, nXCoord, nYCoord
  With this.Parent
    lnActiveRow = ceiling( ;
      ( nYCoord - (.top + .headerheight) ) / .rowheight )
    lnActivecol = this.Columnorder - this.Parent.LeftColumn + 1
    .ActivateCell(lnActiveRow,lnActivecol)
  Endwith
  With this
    If type(.controlsource)$'CM'
      .myControl.Tooltiptext = ;
        iif(type(.controlsource)='C',  eval(.Controlsource),;
        iif(type(.controlsource)='M',  mline(eval(.Controlsource),1),''))
    Endif
  Endwith
Endproc
Enddefine

Define class myGridTxtBox as TextBox
  Name = "Text1"
  Procedure init
  This.BorderStyle = 0
Endproc
  Procedure click
  This.setfocus()
Endproc
  Procedure SwitchColor
  With this.Parent
    .DynamicBackColor = ;
      'iif('+.Controlsource+'="M",'+str(int(rand()*0xFFFFFF))+','+str(.BackColor)+')'
    .Parent.Refresh
  Endwith
Endproc

  Procedure Rightclick
  If this.parent.Columnorder = 3
    *Do myshortcut.mpr with this
    Thisform.SampleShortCut(this)
  Endif
Endproc

Enddefine

Define class myGridChkBox as Container
  Width = 14
  Height = 17
  BackStyle = 0
  BorderWidth = 0
  Name = "grdcheckbox"
  Add OBJECT check1 AS checkbox WITH ;
    Top = 0, ;
    Left = 0, ;
    Height = 17, ;
    Width = 13, ;
    BackStyle = 0, ;
    Caption = "", ;
    Name = "Check1"
  Procedure Init
  With this
    .check1.Controlsource = .parent.controlsource
    .Resize()
  Endwith
Endproc
  Procedure Resize
  With this.check1
    .Left = (this.Parent.Width - .Width)/2
  Endwith
Endproc
Enddefine


Define class myHeader as Header
  BackColor = 0
  ForeColor = rgb(255,255,0)
  Procedure init
  With this
    If !.parent.parent.FreeTable and ;
        !empty(dbgetprop(.parent.controlsource,"Field","Caption"))
      .Caption = dbgetprop(.parent.controlsource,"Field","Caption")
    Else
      .Caption = substr(.parent.controlsource,at('.',.parent.controlsource)+1)
    Endif
  Endwith
Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform