GRID in HMG 3.4.4 - Unable to view (edit) MEMO field contents ?

Moderator: Rathinagiri

franco
Posts: 183
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Re: GRID in HMG 3.4.4 - Unable to view (edit) MEMO field contents ?

Post by franco » Wed Jun 14, 2017 7:38 pm

Here is sample of what I am having trouble with. I am sure I am doing something wrong in 3.4.4.
The DESC text box updates in 3.2 but does not in 3.4.4 on save and refresh in CH Function.
Also I can not remember how to set the curser back to the grid column I left.

Code: Select all

#include "hmg.ch"

Function Main
	FILS()
	set century on
	*IF .NOT. ISWINDOWACTIVE(FORM_2)
		DEFINE WINDOW Form_2 ;
		AT 110, 10 ;			
		WIDTH 1250 ;				
		HEIGHT 700 ;		
		TITLE 'Sales Report Screen' ;			
		MAIN ;
		NOSIZE 	;     
		ON RELEASE {||{Closer2fils()}}  
		
			DEFINE TEXTBOX TEXT_1 	
			ROW 150
			COL 280
			WIDTH 200 
			HEIGHT 20 
			UPPERCASE .T.
			FIELD TEMP5->DESC 
			
		END TEXTBOX

		DEFINE GRID Grid_2
			ROW	200
			COL	30        //140
			WIDTH 1190         //1100
			HEIGHT 200    //370
			BACKCOLOR  { 180, 180, 200}
			FONTCOLOR  { 0, 0, 0 }	
			HEADERS {"Invoice", "Item" ,"Sellprice","Desc"}
			COLUMNCONTROLS { {'TEXTBOX','CHARACTER',"!!!!!!!!"},{'TEXTBOX','CHARACTER',"!!!!!!!!!!!!!!!"},;
							{'TEXTBOX','NUMERIC','9999999.99'},{'TEXTBOX','CHARACTER',"!!!!!!!!!!!!!!!!!!!!!!!!!!"}}
			WIDTHS {80, 95, 100 ,150}
			JUSTIFY {0,0,1,0}
			COLUMNWHEN { { || .T. },{ || .T. }, { || .T. }, { || .T. }}
			ROWSOURCE 'temp5'  
			COLUMNFIELDS { 'INV_NO' , 'ITEM_NO','UNIT_PRICE','DESC'}
			VALUE {1,1}
			ALLOWEDIT .T.
			TABSTOP .F.
			ON CHANGE CH()
		
		END GRID
 
		END WINDOW
		
		
		
		Form_2.Activate
		
	RETURN //NIL
*********************************************************
	Function CH
	local wh := Form_2.Grid_2.value
	Form_2.Grid_2.save
	FORM_2.Text_1.refresh
	form_2.Grid_2.value := wh
	return
	

	Function Fils
		Local CF1 := {}
		CF1 := {}
		aADD(CF1,{'INV_no' , 'C' , 8,0})
		AADD(CF1,{'ITEM_NO', 'C' , 15,0})
		Aadd(CF1,{'DESC',   'C', 26,0})
		Aadd(CF1,{'UNIT_PRICE', 'N' , 10,2})

		if ! hb_dbcreatetemp("temp5", cf1)
			msgbox("Cannot create temporary table: Item")
			RELEASE WINDOW ALL
			return nil
		endif
		if select("temp5") = 0
			use temp5 new
		endif
		select temp5 
		index on inv_no to temp5
		temp := 1
		do while temp < 51
			append blank
			replace inv_no with 'IN'+alltrim(str(temp+1000))
			replace item_no with 'IT'+alltrim(str(temp+100))
			replace unit_price with temp*100
			replace desc with 'DESC '+STR(TEMP)
			temp:=temp+1
			loop
		enddo
		return

	Function CloseR2fils

		close temp5
		release temp5
	
	return
Any thoughts greatly apprieciated... Franco ;)

Marin
Posts: 27
Joined: Tue Dec 20, 2016 1:39 pm
DBs Used: DBF
Location: Bulgaria, Sofia
Has thanked: 20 times
Been thanked: 3 times
Contact:

Post by Marin » Thu Jun 15, 2017 8:30 am

Hi, Franco,

Based on your PRG-fragment I can not formulate your personaly needs exactly, but please read the text below.
You may find it useful.

Regarding "Also I can not remember how to set the curser back to the grid column I left. ".
1. When you set the GRID property CELLNAVIGATION to .T., then you have the ability to get/set the row and column in a grid. In other words, the VALUE property of the GRID-control will return (ROW, COL) coordinates of the current cell in a GRID.
Example:
DEFINE GRID Grid_1
.......
CELLNAVIGATION .T. // Value {x,y} will return (ROW, COL) instead of ROW only

2. In your GRID-control ON CHANGE function:
//* Array to temporary store the (ROW, COL) grid coordinates, where a[1] := ROW, a[2] := COL
LOCAL a := ChildWin_1.Grid_1.VALUE
......
//* Later, you might want to set the (ROW, COL) back in order to return to the same cell in the GRID =>
ChildWin_1.Grid_1.VALUE := { a[1], a[2] }

Regarding "The DESC text box updates in 3.2 but does not in 3.4.4 on save and refresh in CH Function."
1. I would propose you to check whether the GRID.RecNo property corresponds to the DBF->RecNo(). Please, refer to the changelog in hmg3.4.4.

Regards,
Marin

franco
Posts: 183
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Thu Jun 15, 2017 7:22 pm

Hi Marin, Thanks for resonce.
I have grid cell fixed. Still no text box update, the table is set to eof() not to grid item.
I noticed a post on 3.4.4 by Rathi on mar29/17 says:
NOTE: The RECNO property of the Grid control not changes the current physical record number of the DBF file, only convert between the row
of grid and the recno of the DBF.
- Get Grid.RECNO --> convert Logical record ( grid row ) to Physical record ( DBF recno )
- Set Grid.RECNO := XXX --> convert the Physical record XXX ( recno ) to Logical record ( grid row )
I think this is my problem and am going to try in my save grid function. I do not understand why this was cahnged, must be a reason.
Thanks again, Franco ;)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest