CheckBox in a Grid Problem

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: CheckBox in a Grid Problem

Post by AUGE_OHR »

hi Red,
Red2 wrote: Mon Aug 15, 2022 11:06 pm Unfortunately I have been not been able to make this happen using:
1) The HMG IDE
Ok, you want CHECKBOX in GRID, not Color Problem

i have look into Sample and found

Code: Select all

ON CHECKBOXCLICKED
but it is NOT in Form-Designer and not in your *.FMG
so you can use *.FMG whdn "edit" it ... but when "load" it still have not the Codeblock Slot so when "save" it will remove Line

Solution : do not use *.FMG
Red2 wrote: Mon Aug 15, 2022 11:06 pm 2) Displaying a .DBF table instead of a data Array.
BROWSE does not have CHECKBOXCLICKED
have fun
Jimmy
User avatar
mustafa
Posts: 1177
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: CheckBox in a Grid Problem

Post by mustafa »

Hi Red2
with DBF file it is not possible CHECKBOXCLICKED
only imitation can be done

Regards
Salam
Attachments
CheckBox.zip
(5 KiB) Downloaded 104 times
Red2
Posts: 282
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: CheckBox in a Grid Problem

Post by Red2 »

Thank you mustafa.

I appreciate your help.
Your Demo.PRG compiles in the HMG IDE and shows a "CheckBox" I can use.
This is what I want showing in my Grid. Thank you!
This is a big step in the right direction.

I notice that your Demo.PRG:
1) Does not use SetProperty( <Form>, <Griod>, "CheckBoxEnabled", .T. ) so I removed that.
2) Does not specify ColumnControls so in my .FRM I changed that to Nil.
3) Your ColumnFields has Column #1 as 'IIF(STOCK->L,1,0)' so my Column #1 is now "iif(By_State->MergeState,1,0)"
It appears the "iif(NFA_by_State->MergeState, 1, Nil)" also gives similar results (no Zeros show).

Unfortunately my early attempts to create this "CheckBox" in my Grid are not yet successful.
(I'm ignoring BackColor for now).
Column_Nr-1.PNG
Column_Nr-1.PNG (9.57 KiB) Viewed 3775 times
Column #1 displays a DIGIT instead of your "CheckBox".
I will examine both your example and my code to see if I can find what keeps your "CheckBox" from appearing.
If anyone has any helpful ideas or thoughts I would GREATLY appreciate hearing them.

Thanks again to everyone for all your very kind help!
Red2
User avatar
mustafa
Posts: 1177
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: CheckBox in a Grid Problem

Post by mustafa »

Hi Red2
the dbf file the first column has to set field L= logical .F. or .T.
and in the grid you have to place the two bmp files, which makes
make an intention to be CheckBoxEnabled

IMAGE { '02.bmp','01.bmp' }

Regards
Red2
Posts: 282
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: CheckBox in a Grid Problem

Post by Red2 »

Hi mustafa,

Thank you so much for your quick response and expert guidance.

I will work on this later today.
I am excited to see that a Column #1 "CheckBox" will soon happen!

Again, I am most grateful for your kind help!
Red2
Red2
Posts: 282
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: CheckBox in a Grid Problem

Post by Red2 »

Hi mustafa,

Thank you. Because of your generous help, Column #1 now shows a "CheckBox".
I am 98% there! My Grid finally displays a "CheckBox". I'm very pleased.

The last problem is that clicking any Column (after Column #1) also fires this
new "CheckBox" code and Column #1's value is changed. This is a problem.

Instead I need the new "CheckBox" code to ONLY run when Column #1 is clicked!
When any other Column is clicked I need Column #1 to remain UNchanged.

QUESTION: Can anyone help me determine how to detect where on a row that the mouse was clicked?
How can this be determined? With that information I can easily ignore changing Column #1's value.
Problem then solved!

Thank you everyone for all your help!
Red2
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: CheckBox in a Grid Problem

Post by AUGE_OHR »

hi Red,
Red2 wrote: Wed Aug 17, 2022 1:51 am The last problem is that clicking any Column (after Column #1) also fires this
new "CheckBox" code and Column #1's value is changed. This is a problem.
did you use Mustafa Sample where you got

Code: Select all

      CELLNAVIGATION .T.
try to change to .F.
have fun
Jimmy
User avatar
mustafa
Posts: 1177
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: CheckBox in a Grid Problem

Post by mustafa »

Hola amigos:

Nueva modificación para los cuadrados de CheckBox parecen más reales.

Según indicaciones de jimmy se cambia en la Grid ==> CELLNAVIGATION .F.
se suprime de la Grid BACKCOLOR y FONTCOLOR para que los cuadrados
de CheckBox se vean mejor.

Con ONDBLCLIC pulsando doble clic anulamos la marcación o volvemos a marcar
en el cuadro de CheckBox

Saludos
Mustafa

*--------------------------------- Google ------------------------*

Hello friends:

New modification for CheckBox squares look more real.

According to Jimmy's indications, it is changed in the Grid ==> CELLNAVIGATION .F.
BACKCOLOR and FONTCOLOR are deleted from the Grid so that the squares
of CheckBox look better.

With ONDBLCLIC pressing double click we cancel the dialing or we dial again
in the CheckBox

Regards

Mustafa
Attachments
CheckBox1.zip
(7.07 KiB) Downloaded 99 times
franco
Posts: 921
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: CheckBox in a Grid Problem

Post by franco »

Hi, Red2
On all my Grid on change procedure I find where I was and on return go back there.

Code: Select all

Grid on change Pr1()

Function Pr1
Local aCell  
aCell:= Form_1.Grid_1.value
	Go Form_1.Grid_1.Recno          // Update Table
if acell[2] = 1                                  //     acell[1] is row      acell[2] is column.   
      	DO WHAT YOU WANT
	Form_1.Grid_2.value:=aCell
	return
endif
         DO WHAT YOU WANT ALL OTHER ROWS
                Form_1.Grid_2.save
        	Form_1.Grid_2.value:=aCell             // Puts me where I was before change.
return

Still working on my colours.
Franco
All The Best,
Franco
Canada
Red2
Posts: 282
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: CheckBox in a Grid Problem

Post by Red2 »

Hi mustafa,

Thank you once again for your help.

I had trouble with FUNCTION SelecDes() checking and unchecking the "CheckBox".
The following changes worked better for me:

Code: Select all

//	Replace STOCK->L With .F. // <<==== I do not understand the purpose of this line
//	If STOCK->L = .T.
//		Replace STOCK->L With .F.
//		Form_1.Grid_1.Save
//		DoMethod ("Form_1","Grid_1","Refresh")
//	Else
//		Replace STOCK->L With .T.
//		Form_1.Grid_1.Save
//		DoMethod ("Form_1","Grid_1","Refresh")
//	EndIf

// The following seems (to me) a simplification of the above IF...ENDIF
Replace STOCK->L With ( ! STOCK->L )
Form_1.Grid_1.Save
DoMethod ("Form_1","Grid_1","Refresh")
Question:
Is there some way to programmatically identify mouse click coordinates so that
I can stop clicks outside of Column #1 from changing the "CheckBox".
My reason: I only want clicks in Column #1 to check and uncheck.

Thank you again for your great help!
Red2
Post Reply