Change a Grid Readonly On the fly

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Change a Grid Readonly On the fly

Post by sudip »

Hi,

How can I change the Readonly property of a grid on the fly?

I used
frmCompound.grdCompoundrm.readonly := .t.

But it doesn't work.

TIA.

With best regards.

Sudip
With best regards,
Sudip
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Change a Grid Readonly On the fly

Post by esgici »

Hi Sudip

Are you sure that GRID control has ReadOnly property ?

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
gfilatov
Posts: 1067
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Change a Grid Readonly On the fly

Post by gfilatov »

sudip wrote:Hi,

How can I change the Readonly property of a grid on the fly?

I used
frmCompound.grdCompoundrm.readonly := .t.

But it doesn't work.
Hi Sudip,

Try

_HMG_SYSDATA [ 40 ] [ GetControlIndex ( 'grdCompoundrm' , 'frmCompound' ) ] [ 1 ] := .F.

I hope that helps :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Change a Grid Readonly On the fly

Post by sudip »

Hi Esgici,

Actually I am not sure. ;) I can't find Readonly for Grid in Help. But, my code doesn't show any error!!!


Hi Grigory,

Thank you very much. This will be very helpful to me.

Before seeing your code, I tried something with COLUMNWHEN property and it works!!!

Code: Select all

		@ 96, 220 GRID grdCompoundRm ;
			WIDTH 300 ;
			HEIGHT 250 ;
			HEADERS { 'Raw Material', 'Qty', '%' } ;
			WIDTHS { 150, 75, 55 } ;
			COLUMNCONTROLS { { 'COMBOBOX', aRmnm }, ;
			               { 'TEXTBOX', 'NUMERIC', '9999.999' }, ;
			               { 'TEXTBOX', 'NUMERIC', '999.99%' }} ;
			edit ;
			justify { 0, 1, 1 } ;
			on lostfocus CalcTot() ;
			COLUMNWHEN { { || frmCompound.cmdSave.enabled }, ;
				{ || frmCompound.cmdSave.enabled }, { || .f. } }
With best regards.

Sudip
With best regards,
Sudip
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Change a Grid Readonly On the fly

Post by sudip »

Hello Grigory,

Thank you very much for your tip!!! It works!!! :D

But, I have to remember the line ...

_HMG_SYSDATA [ 40 ] [ GetControlIndex ( 'grdCompoundrm' , 'frmCompound' ) ] [ 1 ] := .F.

BTW, is there any documentation for _HMG_SYSDATA?

With best regards.

Sudip
With best regards,
Sudip
User avatar
gfilatov
Posts: 1067
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Change a Grid Readonly On the fly

Post by gfilatov »

sudip wrote:Hello Grigory,

...
BTW, is there any documentation for _HMG_SYSDATA?
Sudip,

Take a look for h_init.prg at your folder hmg\SOURCE. :arrow:
* _HMG_SYSDATA Reference ;)

* _HMG_SYSDATA [ 1 ] -> Control Data
* _HMG_SYSDATA [ 2 ] -> Control Data
* _HMG_SYSDATA [ 3 ] -> Control Data
* _HMG_SYSDATA [ 4 ] -> Control Data
* _HMG_SYSDATA [ 5 ] -> Control Data
* _HMG_SYSDATA [ 6 ] -> Control Data
* _HMG_SYSDATA [ 7 ] -> Control Data
* _HMG_SYSDATA [ 8 ] -> Control Data
* _HMG_SYSDATA [ 9 ] -> Control Data
* _HMG_SYSDATA [ 10 ] -> Control Data
* _HMG_SYSDATA [ 11 ] -> Control Data
* _HMG_SYSDATA [ 12 ] -> Control Data
* _HMG_SYSDATA [ 13 ] -> Control Data
* _HMG_SYSDATA [ 14 ] -> Control Data
* _HMG_SYSDATA [ 15 ] -> Control Data
* _HMG_SYSDATA [ 16 ] -> Control Data
* _HMG_SYSDATA [ 17 ] -> Control Data
* _HMG_SYSDATA [ 18 ] -> Control Data
* _HMG_SYSDATA [ 19 ] -> Control Data
* _HMG_SYSDATA [ 20 ] -> Control Data
* _HMG_SYSDATA [ 21 ] -> Control Data
* _HMG_SYSDATA [ 22 ] -> Control Data
* _HMG_SYSDATA [ 23 ] -> Control Data
* _HMG_SYSDATA [ 24 ] -> Control Data
* _HMG_SYSDATA [ 25 ] -> Control Data
* _HMG_SYSDATA [ 26 ] -> Control Data
* _HMG_SYSDATA [ 27 ] -> Control Data
* _HMG_SYSDATA [ 28 ] -> Control Data
* _HMG_SYSDATA [ 29 ] -> Control Data
* _HMG_SYSDATA [ 30 ] -> Control Data
* _HMG_SYSDATA [ 31 ] -> Control Data
* _HMG_SYSDATA [ 32 ] -> Control Data
* _HMG_SYSDATA [ 33 ] -> Control Data
* _HMG_SYSDATA [ 34 ] -> Control Data
* _HMG_SYSDATA [ 35 ] -> Control Data
* _HMG_SYSDATA [ 36 ] -> Control Data
* _HMG_SYSDATA [ 37 ] -> Control Data
* _HMG_SYSDATA [ 38 ] -> Control Data
* _HMG_SYSDATA [ 39 ] -> Control Data
* _HMG_SYSDATA [ 40 ] -> Control Data
...
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Change a Grid Readonly On the fly

Post by sudip »

Hi Grigory,

Thank you sooooo much :)

Now, I have another problem. I want to autocaluclate some total amount from grid. What event shall I use?

1) On change
2) COLUMNVALID
3) LostFocus

Previously I used On Change, but I found that it works only if Row or Col value is changed.

TIA.

With best regards.

Sudip
With best regards,
Sudip
User avatar
gfilatov
Posts: 1067
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Change a Grid Readonly On the fly

Post by gfilatov »

sudip wrote:Hi Grigory,

Thank you sooooo much :)

Now, I have another problem. I want to autocaluclate some total amount from grid. What event shall I use?

1) On change
2) COLUMNVALID
3) LostFocus

Previously I used On Change, but I found that it works only if Row or Col value is changed.
Hi Sudip,

I vote for 2) COLUMNVALID ;)

Code: Select all

/*
* MiniGUI Virtual Column Grid Demo
* (c) 2006-2009 Grigory Filatov
*/

#include "minigui.ch"

PROCEDURE Main

Local aRows [20] [6]

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 ;
		HEIGHT 420 ;
		TITLE 'Virtual Column Grid Test' ;
		MAIN 

		DEFINE MAIN MENU
			DEFINE POPUP 'File'
				MENUITEM 'Set Item'	ACTION SetItem()
				MENUITEM 'Get Item'	ACTION GetItem()
				SEPARATOR
				MENUITEM 'Exit'	ACTION ThisWindow.Release
			END POPUP
		END MENU

		aRows [1]	:= {'01','Simpson','Homer',5,10,5*10}
		aRows [2]	:= {'02','Mulder','Fox',24,32,24*32} 
		aRows [3]	:= {'03','Smart','Max',43,58,43*58} 
		aRows [4]	:= {'04','Grillo','Pepe',89,23,89*23} 
		aRows [5]	:= {'05','Kirk','James',34,73,34*73} 
		aRows [6]	:= {'06','Barriga','Carlos',39,54,39*54} 
		aRows [7]	:= {'07','Flanders','Ned',43,11,43*11} 
		aRows [8]	:= {'08','Smith','John',12,34,12*34} 
		aRows [9]	:= {'09','Pedemonti','Flavio',10,100,10*100} 
		aRows [10]	:= {'10','Gomez','Juan',58,32,58*32} 
		aRows [11]	:= {'11','Fernandez','Raul',32,43,32*43} 
		aRows [12]	:= {'12','Borges','Javier',26,30,26*30} 
		aRows [13]	:= {'13','Alvarez','Alberto',54,98,54*98} 
		aRows [14]	:= {'14','Gonzalez','Ambo',43,73,43*73} 
		aRows [15]	:= {'15','Batistuta','Gol',48,28,48*28} 
		aRows [16]	:= {'16','Vinazzi','Amigo',39,83,39*83} 
		aRows [17]	:= {'17','Pedemonti','Flavio',53,84,53*84} 
		aRows [18]	:= {'18','Samarbide','Armando',54,73,54*73} 
		aRows [19]	:= {'19','Pradon','Alejandra',12,45,12*45} 
		aRows [20]	:= {'20','Reyes','Monica',32,36,32*36} 

		@ 10,10 GRID Grid_1 ;
			WIDTH 612 ;
			HEIGHT 344 ;
			HEADERS { 'Code', 'Last Name', 'First Name', 'Quantity', 'Price', 'Cost' } ;
			WIDTHS {60,100,100,80,80,100} ;
			ITEMS aRows ;
			EDIT ;
			COLUMNCONTROLS  { ;
					{'TEXTBOX','CHARACTER', '999' } , ;
					{'TEXTBOX','CHARACTER', } , ;
					{'TEXTBOX','CHARACTER', } , ;
					{'TEXTBOX','NUMERIC', '9,999' } , ;
					{'TEXTBOX','NUMERIC', '999.99' } , ;
					{'TEXTBOX','NUMERIC', '9,999,999.99' } ;
					};
			COLUMNWHEN { ;
					{ || Empty ( This.CellValue ) } , ;
					{ || This.CellValue >= 'M' } , ;
					{ || This.CellValue >= 'C' } , ;
					{ || ! Empty ( This.CellValue ) }, ;
					{ || ! Empty ( This.CellValue ) }, ;
					{ || Empty ( This.CellValue ) } ;
					} ;
			COLUMNVALID { , , , ;
					{ || SETVIRTUALITEM() } , ;
					{ || SETVIRTUALITEM() } , ;
					} ;
			JUSTIFY { GRID_JTFY_RIGHT,;
				GRID_JTFY_LEFT,;
				GRID_JTFY_LEFT,;
				GRID_JTFY_RIGHT,;
				GRID_JTFY_RIGHT,;
				GRID_JTFY_RIGHT }

	END WINDOW

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return

Function SETVIRTUALITEM()
local nVal := This.CellValue
local nCol := This.CellColIndex
local nRow := This.CellRowIndex

if nCol == 4
	Form_1.Grid_1.Cell( nRow , 6 ) := nVal * Form_1.Grid_1.Cell( nRow , 5 )
elseif nCol == 5
	Form_1.Grid_1.Cell( nRow , 6 ) := Form_1.Grid_1.Cell( nRow , 4 ) * nVal
endif

RETURN .T.

PROCEDURE SETITEM()

	Form_1.Grid_1.Item (2) := { '02', 'Gomez', 'Juan' , Form_1.Grid_1.Cell( 1 , 4 ), Form_1.Grid_1.Cell( 1 , 5 ), Form_1.Grid_1.Cell( 1 , 4 ) * Form_1.Grid_1.Cell( 1 , 5 ) }

RETURN

PROCEDURE GETITEM()
local a

	a := Form_1.Grid_1.Item (2)

	aEval( a, {|x,i| msginfo ( if(valtype(x)=="C", x, str(x)), ltrim( str ( i ) ) )} )

RETURN
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Change a Grid Readonly On the fly

Post by sudip »

Hello Grigory,

Thanks a lot! Now, I understand. :)

With best regards.

Sudip
With best regards,
Sudip
Post Reply