Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid Control and a table memo field
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00638117
Message ID:
00638533
Views:
17
>Dennis, I had the same question last week on this and decided that I would use a textcontrol. Originally, I placed an EDITBOX into the grid, but since it didn't open up, I went back to the Textbox control and selected LEFT(memofieldname,100). This basically solved my problem and gave me a preview of what was in the memo field.
>
>It would still be nice though, if we could somehow open the memo field up in the EDITBOX control in a grid. If anyone knows how to do this, "I'm all ears", as quoted by Ross Perot in his bid for the Presidency a few years ago.
>
>Cecil

Cecil,

There are two ways. I've been using method (1) for years

(1) Subclass the editbox, put your editbox in the grid, set the column.Sparse to .F. Now you can see the contents (at least the first line) of the memo.

To open the memo field on eg space, put in the keypress of the editbox
LPARAMETERS nKeyCode, nShiftAltCtrl

do case
case nKeyCode = asc(' ')
    NODEFAULT
    if( !empty(this.ControlSource) )
	push key
	on key label F7 keyboard '{CTRL+W}' && eg F7 to save
	on key label TAB keyboard '{CTRL+W}' && or TAB to save
        local _form
	_form = iif(type('thisform') == T_OBJECT, thisform.Name, 'screen')
				
	if( this.ReadOnly )
	    modify memo (this.ControlSource) NOEDIT NOMENU in (_form)
	else	    		
	    modify memo (this.ControlSource) NOMENU in (_form)
	endif
	pop key
    endif
endcase
(2) put an editbox in the grid (for memo fields, this is), set the column.Sparse to .F. Now you can see the contents (at least the first line) of the memo, or more depending on the rowHeight of the grid

Logic:
- Intercept keystrokes
- if blank pressed while an editbox was active
and the editbox is in a grid

popup a window which lets the user see the full contents of the memo, and edit if the editbox is not readonly

Form.KeyPress. Needs Form.KeyPreview = .T.
do case
case nKeyCode = asc(' ')
    local ac
    ac = thisform.GetActiveControl()
    if( !isNull(ac) )
        if( ac.BaseClass == 'Editbox' )
            if( ac.Parent.BaseClass = 'Column' )
                if( !empty(ac.ControlSource) )
	            push key
	            on key label F7 keyboard '{CTRL+W}' && eg F7 to save
	            on key label TAB keyboard '{CTRL+W}' && or TAB to save
                    local _form
	            _form = iif(type('thisform') == T_OBJECT, thisform.Name, 'screen')
				
	            if( ac.ReadOnly )
	               modify memo (ac.ControlSource) NOEDIT NOMENU in (_form)
	            else	    		
	               modify memo (ac.ControlSource) NOMENU in (_form)
	           endif
	          pop key
              endif
           endif
        endif
    endif
endcase
&& GetActiveControl
lparameters	DoNotGoDownIfGrid

local	_ActiveControl, _ActiveColumn, i, x

if( type('thisform.ActiveControl') == T_UNDEFINED )
	return .Null.
else
	_ActiveControl = thisform.ActiveControl
endif

if( !(type('_ActiveControl') == T_OBJECT ) )
	suspend
endif

if( !DoNotGoDownIfGrid and (Proper(_ActiveControl.BaseClass) == 'Grid') )
	_ActiveColumn = _ActiveControl.ActiveColumn
	
	if( !empty(_ActiveColumn) )
		for i = 1 to _ActiveControl.ColumnCount
				x = _ActiveControl.Columns[i]
			if( x.ColumnOrder == _ActiveColumn )
				exit
			endif
		endfor
		for i = 1 to x.ControlCount
			if ( x.Controls[i].Name == x.CurrentControl )
				_ActiveControl	= x.Controls[i]
				exit
			endif
		endfor
	endif
endif

return _ActiveControl
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform