Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memo field in browse 2

Status
Not open for further replies.

Nro

Programmer
May 15, 2001
337
CA
Hello
Is it possible to open a Memo field programmatically when you browse a file? I can’t use a grid because it’s a legacy application.
Thank in advance.
 
In Browse, you can create "calculated fields" so your field expression would be either MLINE(memofield,1) or Left(memofield,80) or whatever expression gets as much of the memo field as you need.

You can also get an object reference on the browse and deal with it like a grid:

Code:
Browse Name Foo
Foo.Rowheight = Foo.Rowheight * 2
* etc.

Deep in its bone marrow a Browse window is just a grid.
 
If you want to use a grid, use the NAME parameter of the BROWSE command.

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Another possibility:

- Move the record pointer to the desired row.

- Then execute [tt]KEYBOARD '{TAB}'[/tt] as many times as necessary to move the highlight to the relevant column.

- Then [tt]KEYBOARD '{CTRL+HOME}'[/tt]

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
An imperfect demo:
Code:
RAND(-1)
CREATE CURSOR aa (ii I AUTOINC, aa C(10) DEFAULT SYS(2015),bb M DEFAULT genstring())
FOR lni=1 TO 10
	APPEND BLANK
NEXT
BROWSE NOWAIT NAME grd
grd.column3.removeobject("text1")
grd.column3.addobject("edt","editbox")
grd.column3.edt.visible=.T.
grd.column3.currentcontrol="edt"
grd.column3.width=400
grd.rowheight=100
grd.column3.sparse=.F.



FUNCTION genstring
	LOCAL lnLen,lni,lcS,lnChar
	lcS=""
	lnLen=1+INT(1000*RAND())
	FOR lni=0 TO m.lnLen
		lnChar=INT(26*RAND())
		lcS=m.lcS+IIF(m.lnChar=0,SPACE(1),CHR(64+m.lnChar))
	NEXT
	RETURN m.lcS
endfunc

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
I do this all the time but I reserve an area below the grid for the memo details, in an EDIT box
In the afterrowcolchange I issue a refresh
 
I do this all the time but I reserve an area below the grid for the memo details, in an EDIT box
In the afterrowcolchange I issue a refresh

A good approach. But Mr. Nro made it clear that he is using a browse, not a grid.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Yes Mike,

but dan also is right that a brows also is a grid you can address by using the NAME clause of BROWSE, or does this not apply to legacy Foxpro?

It should just be
Code:
Browse Name Foo [COLOR=red]NOWAIT[/color]
Or the code after Browse will only run after the browse window is closed.

If the grid is not part of legacy foxpro screens it may still be in browse, just hardwired inside it, so try that first.

Bye, Olaf.

PS: There also is forum182, and asking there is making clear you have the limited command set of the older FoxPro version.
 
I guess I found what was sometimes causes the flickering, in my previous post (but I'm not sure).
I guess editboxe's scrollbars can cause problems, so I simply added a :
grd.column3.edt.scrollbars=0
Code:
RAND(-1)
CREATE CURSOR aa (ii I AUTOINC, aa C(10) DEFAULT SYS(2015),bb M DEFAULT genstring())
FOR lni=1 TO 100
	APPEND BLANK
NEXT
GO TOP
BROWSE NOWAIT NAME grd
grd.column3.removeobject("text1")
grd.column3.addobject("edt","editbox")
grd.column3.edt.visible=.T.
grd.column3.edt.scrollbars=0    &&&&& 
grd.column3.currentcontrol="edt"
grd.column3.width=400
grd.rowheight=100
grd.column3.sparse=.F.



FUNCTION genstring
	LOCAL lnLen,lni,lcS,lnChar
	lcS=""
	lnLen=1+INT(1000*RAND())
	FOR lni=0 TO m.lnLen
		lnChar=INT(26*RAND())
		lcS=m.lcS+IIF(m.lnChar=0,SPACE(1),CHR(64+m.lnChar))
	NEXT
	RETURN m.lcS
endfunc

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Then it depends what legacy means, at this time you may call any VFP Application up to VFP8 a legacy application, if you define that for applications in languages out of any MS support. If you apply the term to "inherited, written by someone else" applications, that can be true for anything.

Bye, Olaf.
 
Warning! Warning! Danger! Danger!

Be VERY VERY careful how you use BROWSE. It's the single most UI control in VFP that can cause data corruption, not just the stuff that's hard to detect, but data validation is difficult. Best things you can do if you have to use BROWSE: Always use BROWSE over a readonly cursor. Better yet, use a Grid.

Craig Berntson
MCSD, Visual C# MVP,
 
Warning! Warning! Danger! Danger!

Curmudgeons will not read the whole thread. [pipe]
 
Thanks for all your suggestions.

I’ll go with danfreeman code. My user want to see the first memo line, so I’ll show the first line, and give him the option to open the memo field if he wants

Code:
USE p:\apps\develop\dbf\iv_det.dbf IN 0 SHARED
USE p:\apps\develop\dbf\pro_pro1.dbf IN 0 SHARED
SET ORDER TO TAG Pro_no OF p:\apps\develop\dbf\pro_pro1.cdx IN Pro_pro1
Select iv_det
SET RELATION TO Iv_det.tv_prono INTO Pro_pro1 ADDITIVE
BROWSE NOMODIFY NODELETE NOAPPEND FIELDS pro_pro1.pro_name, Tv_REM, M_Rems = LEFT(TV_REM,100) :H='Remark' :100

It’s a legacy application that’s running in VFP 9 and the restrictions is that that I’m using a related field in the browse (read-only). I have no budget to re-write everything, so this solution is great.

Thanks again.
 
If it's running in VFP9 you can make use of the NAME clause, that won't need a rewrite of everything else, eg

BROWSE NOMODIFY NODELETE NOAPPEND FIELDS pro_pro1.pro_name, Tv_REM NAME oBrowseGrid NOWAIT
With oBrowseGrid.Column2
.Addobject("Edit1","Editbox")
.CurrentControl="Edit1"
.RemoveObject("Text1")
.Sparse=.F.
.Edit1.Visible = .T.
Edwith

With a higher rowheight you can show more than a line.

Bye, Olaf.
 
Hello Olaf. The NAME option is great, but it change the browse behaviour (my users hate that when I do it…)

Before I open the window, I bind the rightmouse and the enter key to CHR(23) , so they just have to right click or press enter to close the browse window. If I have an edit box and, they click in it to see the contents (and they will), they have to close the browse window manually. Also, if they are in the edit box, they can’t use page up or page down to change row.

Code:
CLEAR ALL 
CLOSE ALL

USE p:\apps\develop\dbf\iv_det.dbf IN 0 SHARED
USE p:\apps\develop\dbf\pro_pro1.dbf IN 0 SHARED
SET ORDER TO TAG Pro_no OF p:\apps\develop\dbf\pro_pro1.cdx IN Pro_pro1
SET RELATION TO Iv_det.tv_prono INTO Pro_pro1 ADDITIVE
SELECT iv_det

M_OLDRMOUSE = ON("KEY","RIGHTMOUSE")
M_OLDENTER  = ON("KEY","ENTER")

ON KEY LABEL RIGHTMOUSE KEYB CHR(23)
ON KEY LABEL ENTER KEYB CHR(23)

BROWSE NOMODIFY NODELETE NOAPPEND FIELDS pro_pro1.pro_name, Tv_REM :70 NAME oBrowseGrid NOWAIT

With oBrowseGrid.Column2
.Addobject("Edit1","Editbox")
.CurrentControl="Edit1"
.RemoveObject("Text1")
.Sparse=.F.
.Edit1.Visible = .T.
ENDWITH

oBrowseGrid.RowHeight= 30


ON KEY LABEL RIGHTMOUSE &M_OLDRMOUSE
ON KEY LABEL ENTER &M_OLDENTER


Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top