Grid not move columns

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Grid not move columns

Post by mustafa »

Grid no mover las Columnas

Hola amigos:
No soy capaz de encontar ninguna función,
para que el usuario no pueda mover las columnas
del Grid.
Que no pueda agrandar ni disminuir la columna.

He visto que en TSbrowse hay un sample
que congela la segunda columna con
nFreeze := 2

Alguna solución ?
Gracias
*--------------------------------------------------*
Grid not move columns

Hello friends:
I am not able to locate any function
so that the user can not move columns
the Grid.
And can not enlarge or diminish the column.

I have seen that there is a sample in TSbrowse
freezing the second column
nFreeze: = 2

Any solution ?
Thank you
Mustafa :idea:
Attachments
Grid_NotColum.jpg
Grid_NotColum.jpg (49.83 KiB) Viewed 4940 times
Carlos Britos
Posts: 245
Joined: Sat Aug 02, 2008 5:03 pm

Re: Grid not move columns

Post by Carlos Britos »

Hola
Si el grid no usa el scroll horizontal puedes remover el header del grid y poner labels en su lugar. Hasta donde se no se pueden fijar las columnas
Regards/Saludos, Carlos (bcd12a)
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Grid not move columns

Post by andyglezl »

Hola Mustafa
Yo en cierto momento, restauro los anchos de las columnas por medio de un boton con lo siguiente:
---------------------------------------------------------------------------------------------------------------------
Hi Mustafa
I at one point, restore the widths of the columns by means of a button with the following:

Code: Select all

FUNCTION AnchoCol3( cForm, cCtrol, aHeaders )
	LOCAL i1
	FOR i1 = 1 TO LEN( aHeaders )
		SetProperty( cForm, cCtrol, "ColumnWIDTH", i1, GRID_WIDTH_AUTOSIZEHEADER )
	NEXT
RETURN( nil )
Sería cuestion de ver como implementarlo al momento cuando se detecte que se altero el ancho de la columna. ( o con un Timer )
---------------------------------------------------------------------------------------------------------------------------------------------------------
It is a matter of seeing how to implement it at the time when it detects that the width of the column is altered. (Or a timer)
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: Grid not move columns

Post by mustafa »

Hola Andrés
No entiendo mucho tu explicación
Podrías poner un pequeño sample
Muchas Gracias
Mustafa
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: Grid not move columns

Post by mustafa »

Hola Andres
He mirado tu post
viewtopic.php?f=24&t=4575&p=43718&hilit ... ERS#p43718
Me supongo que debe de haber una razón, quizá la propiedad se escriba distinto pero el fin es el mismo.
Con "@ ... " si NO colocas la propiedad NOHEADERS, APARECEN los encabezadoos, SI la pones, NO aparecen.

Con "DEFINE" le indicas a SHOWHEADERS ( .T. o .F. ) si los quieres o no,
con SHOWHEADERS .F.
queda la columna fija

Mustafa
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Grid not move columns

Post by andyglezl »

Hola Mustafa

Aqui el ejemplo...
( es para restaurar el ancho de las columnas, no evita que las modifiquen. )

Code: Select all

#include "hmg.ch"

FUNCTION MAIN()

	DEFINE WINDOW Form_1 AT 0,0 WIDTH 450 HEIGHT 500 TITLE 'Restaura ancho de columnas' MAIN 

		aCols = { 'Column 1', 'Column 2', 'Column 3' }
		@ 010,010 GRID Grid_1 WIDTH 400 HEIGHT 330 HEADERS aCols WIDTHS {140,140,140}  ;
				  VIRTUAL ITEMCOUNT 100 ON QUERYDATA QueryTest() 
	
		@ 360,020 LABEL LBL_1 VALUE "Alterar el ancho de las columnas y oprimir BOTON 'Restaura'" WIDTH 365 HEIGHT 24 ;
				  FONT 'Arial' SIZE 9 FONTCOLOR RED
				  
		@ 380,020 BUTTON Btn_1 CAPTION "Restaura" WIDTH 60 HEIGHT 20 FONT "Arial" SIZE 9 ACTION AnchoCol3( "Form_1", "Grid_1", aCols ) ;
                  TOOLTIP "Restaura ancho de columnas"
		
	END WINDOW
	CENTER WINDOW Form_1
	ACTIVATE WINDOW Form_1

RETURN

PROCEDURE QueryTest()
	This.QueryData := Str ( This.QueryRowIndex ) + ',' + Str ( This.QueryColIndex ) + " - Un texto largo"
RETURN

FUNCTION AnchoCol3( cForm, cCtrol, aHeaders )
   LOCAL i1
   FOR i1 = 1 TO LEN( aHeaders )
      SetProperty( cForm, cCtrol, "ColumnWIDTH", i1, GRID_WIDTH_AUTOSIZEHEADER )
   NEXT
RETURN( nil )
con SHOWHEADERS .F.
queda la columna fija
Sobre el SHOWHEADERS .F. es como te menciona Carlos Britos para que no alteren el ancho de la columna
Si el grid no usa el scroll horizontal puedes remover el header del grid y poner labels en su lugar.
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: Grid not move columns

Post by mustafa »

Hola Andrés
Gracias por tu sample
Pero lo que estoy buscando es que el usuario no pueda
mover las columnas y creo que con un truco que se
me ha ocurrido de combinar SHOWHEADERS .F.
que no sale las cabeceras de las columnas y pongo
con IMAGE una cabecera falsa , que a mi entender
soluciona el no tener ningún comando como
nFreeze de -> TSbrowse

Aquí dejo mi sample.
Saludos
*----------------------------------------------------------------*
Hello Andrés
Thank you for your sample
But what I'm looking for is that the user can not
move columns and I think that is a trick
I happened to combine SHOWHEADERS .F.
that does not leave the column headers and put
IMAGE with a false header, which I believe
solves not having any command as
nFreeze of -> TSbrowse

Here is my sample.
regards

Mustafa
Attachments
Grid_not_move_columns.zip
(8.88 KiB) Downloaded 222 times
screenshot.jpg
screenshot.jpg (19.31 KiB) Viewed 4712 times
EduardoLuis
Posts: 682
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina

Re: Grid not move columns

Post by EduardoLuis »

Hola Mustafá:

La solución que aplicás es - a mi entender - correcta.-
Te sugiero que cuando utilices gráficos, como en este caso, que el gráfico no contenga pixels cuyo color pueda o no coincidir con el color de fondo de la pantalla.-
En el .JPG que diseñaste dejas fuera de las líneas de recuadro 4 pixels de fondo a la izquierda, 3 pixels en el margen superior y 2 en el derecho.- Si por cualquier circunstancia no coincidieran los colores, el efecto buscado se malograría.-
Es solo una recomendación basada en que yo aplico en mis app que, por cierto, utilizan infinidad de gráficos ya sea para simular menu tabs, buttons, etc.-
Espero que esta recomendación te sea util.-
Eduardo
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Grid not move columns

Post by serge_girard »

Mustafa,

Why don't you use SHOWHEADERS .F. in Grid_2 and

Code: Select all

    
DEFINE IMAGE Fondo_2
     ROW 280 ; COL 046 ; WIDTH 706 ; HEIGHT 025          
     PICTURE  "cabecera.jpg"      
     STRETCH .T.
END IMAGE
All just like Grid_1 !

Serge
There's nothing you can do that can't be done...
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Grid not move columns

Post by andyglezl »

Hola Mustafa

Me permiti hacerle unas modificaciones a tu codigo para que se utilice LABEL ( no IMAGE )
Siento que el ToolTip está de más, ya que se estan desplegando los encabezados...

Code: Select all

#include "hmg.ch"

Function Main

*----------------------------------------*
* (c) Mustafa López  mustalopez@gmail.com
*----------------------------------------*
  REQUEST DBFCDX , DBFFPT , DBFDBT
  RDDSETDEFAULT( "DBFCDX" )

  REQUEST HB_CODEPAGE_ESWIN     
  HB_SETCODEPAGE("ESWIN")    
 
  REQUEST HB_LANG_ES   
  HB_LANGSELECT("ES")  
*----------------------------------*
  SET CENTURY ON
  SET DATE FRENCH
  SET ESCAPE ON
  SET NAVIGATION EXTENDED
  SET LANGUAGE TO SPANISH 
  SET CODEPAGE TO SPANISH
  SET DELETED ON
  SET DATE FORMAT TO 'dd/mm/yyyy'
  SET BROWSESYNC ON
  SET TOOLTIPSTYLE BALLOON
*---------------------------------*
private reg , _campo2 
private cNome
private nCelRow 
private nCelCol 

   DEFINE WINDOW Form_1Q          ;
      AT 0,0                      ;
      WIDTH 800                   ;
      HEIGHT 610                  ;
      TITLE "Grid not move columns & CheckBox" ;    
      NOSIZE NOMAXIMIZE           ;
      MAIN                        ;
      ON INIT  OpentablesQ() 

      fColor := { || if ( This.CellRowIndex/2 == int(This.CellRowIndex/2) , BLUE , RED ) }
      bcolor := { || if ( This.CellRowIndex/2 = int (This.CellRowIndex/2) , {180,200,255} , {255,255,211} ) }   
         
*-------------------------- Cabecera GRid_1 ---------------------------------------*
       *DEFINE IMAGE Fondo_1
       *    ROW 046 ; COL 046 ; WIDTH 706 ; HEIGHT 025          
       *    PICTURE  "cabecera.jpg"      
       *    STRETCH .T.
       *END IMAGE
*----------------------------------------------------------------------------------*

     @ 15,320 LABEL Label_1 Value "Select Products"  Width  440  Height 032     ; 
                    FONT "Arial" SIZE 17 BOLD ITALIC        

*------------------------------- Color Barra Video Inversa ------------------------*
  _HMG_SYSDATA [ 348 ] := { 199,250,225 }    
  _HMG_SYSDATA [ 349 ] := { 007,071,041 }   
  _HMG_SYSDATA [ 350 ] := { 235,237,095 }   
  _HMG_SYSDATA [ 351 ] := { 069,015,135 }  
*----------------------------------------------------------------------------------*

        SELECT 1
        USE STOCK INDEX STOCK
		
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- AGL
	aCols= { '','Ref','Producto','Tipo' ,  'Precio'  ,  'C_Barras' }
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-	AGL

   DEFINE GRID Grid_1
      ROW     070  
      COL     050
      WIDTH   700
      HEIGHT  177  
      HEADERS  aCols  // no sale con  SHOWHEADERS .F. 
      WIDTHS  { 17, 122 , 149 , 135 , 116 , 138 }
      VALUE 0  
      IMAGE   { '02.bmp','01.bmp' }   
      JUSTIFY { GRID_JTFY_LEFT, GRID_JTFY_RIGHT, GRID_JTFY_LEFT , GRID_JTFY_LEFT, GRID_JTFY_RIGHT, GRID_JTFY_LEFT} 
      DYNAMICFORECOLOR { fColor , fColor, fColor , fColor, fColor, fColor } 
      DYNAMICBACKCOLOR { bColor , bColor, bColor , bColor, bColor, bColor }  
      BACKCOLOR { 209,238,238 }
      FONTCOLOR { 000,255,020 } 
      ONCHANGE ( Co_ToolTip("Form_1Q","Grid_1") , SelecDes() )
      MULTISELECT .F.
      SHOWHEADERS .F. 
      ROWSOURCE "STOCK"
      COLUMNFIELDS { 'IIF(STOCK->L,1,0)', 'STOCK->REF','STOCK->PRODUCTO','STOCK->TIPO','STOCK->PRECIO','STOCK->CBARRAS' }
      FONTNAME 'Arial'
      FONTSIZE 9
      CELLNAVIGATION .T.
    END GRID
	
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- AGL
	nCol = 069
	FOR i1 = 2 TO LEN( aCols )
		nAncho = GetProperty( "Form_1Q", "Grid_1", "ColumnWIDTH", i1 )
		xLB = "Label_1"+STRZERO( i1, 2 )
		@ 049,nCol LABEL &xLB Value aCols[ i1 ] Width nAncho  Height 20 FONT "Verdana" SIZE 10 CENTERALIGN ;
					FONTCOLOR WHITE BACKCOLOR BLUE
		xLB = "Label_2"+STRZERO( i1, 2 )
		@ 285,nCol LABEL &xLB Value aCols[ i1 ] Width nAncho  Height 20 FONT "Verdana" SIZE 10 CENTERALIGN ;
					FONTCOLOR WHITE BACKCOLOR BLUE					
		nCol += GetProperty( "Form_1Q", "Grid_1", "ColumnWIDTH", i1 )
	NEXT
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- AGL
	
    @ 255,318 LABEL Label_2 Value "Product Selection " Width  440  Height 20 ; 
                     FONT "Arial" SIZE 17 BOLD ITALIC 
             
        SELECT 2   
        USE STOCKP 
        dbgobottom() 

   DEFINE GRID Grid_2
      ROW     305
      COL     050
      WIDTH   700
      HEIGHT  175 
      HEADERS { 'Ref','Producto','Tipo' ,'Precio','C_Barras' }
      WIDTHS  {139, 149, 135, 116, 140}
      ITEMS {{""}}
      VALUE 1  
      ONCHANGE  Co_ToolTip2("Form_1Q","Grid_2") 
      ROWSOURCE "STOCKP"
      COLUMNFIELDS { 'STOCKP->REF','STOCKP->PRODUCTO','STOCKP->TIPO','STOCKP->PRECIO','STOCKP->CBARRAS' }
      FONTNAME 'Arial'
      FONTSIZE 9
      JUSTIFY { GRID_JTFY_RIGHT , GRID_JTFY_LEFT, GRID_JTFY_LEFT, GRID_JTFY_RIGHT , GRID_JTFY_LEFT}  
      DYNAMICFORECOLOR { fColor, fColor , fColor, fColor, fColor }  
      DYNAMICBACKCOLOR { bColor, bColor , bColor, bColor, bColor }  
      BACKCOLOR { 209,238,238 } 
      FONTCOLOR { 000,255,020 }
	  SHOWHEADERS .F. 
   END GRID

      @ 515, 200 BUTTON Button_2  CAPTION "Delete Base" ACTION Deleter()
      @ 515, 365 BUTTON Button_3  CAPTION "Check List"  ACTION GetListSelect()   
      @ 515, 580 BUTTON Button_4  CAPTION "Exit" ACTION Form_1Q.Release

   END WINDOW

   CENTER WINDOW Form_1Q
   ACTIVATE WINDOW Form_1Q

Return

*---------------------------------------------------*
Function Co_ToolTip(cParentForm,cControl)  // Grid_1
*---------------------------------------------------*

Local nColumn:=GetProperty(cParentForm,cControl,"CellColFocused")
* Do Case
*   Case nColumn=1
*        _SetToolTip(cControl,cParentForm,"")          // no poner nada están los botones
*   Case nColumn=2
*        _SetToolTip(cControl,cParentForm,"Ref")
*   Case nColumn=3
*        _SetToolTip(cControl,cParentForm,"Producto")
*   Case nColumn=4
*        _SetToolTip(cControl,cParentForm,"Tipo")
*   Case nColumn=5
*        _SetToolTip(cControl,cParentForm,"Precio")
*   Case nColumn=6
*        _SetToolTip(cControl,cParentForm,"C_Barras")
* EndCase
Return Nil

*---------------------------------------------------*
Function Co_ToolTip2(cParentForm,cControl)   // Grid_2
*---------------------------------------------------*
*	Local nColumn:=GetProperty(cParentForm,cControl,"CellColFocused")
*
* Do Case
*   Case nColumn=1
*        _SetToolTip(cControl,cParentForm,"Ref")
*   Case nColumn=2
*        _SetToolTip(cControl,cParentForm,"Producto")
*   Case nColumn=3
*        _SetToolTip(cControl,cParentForm,"Tipo")
*   Case nColumn=4
*        _SetToolTip(cControl,cParentForm,"Precio")
*   Case nColumn=5
*        _SetToolTip(cControl,cParentForm,"C_Barras")
* EndCase
Return Nil
*---------------------------------------------*
Function OpentablesQ()
*---------------------------------------------*
        CLOSE DATABASES
        SELECT 1 
        USE STOCK
        DELETE FOR REF := 0
        PACK
        CLOSE DATABASES

        SELECT 1 
        USE STOCK NEW
        INDEX ON STR(REF) TO STOCK
        CLOSE DATABASES

        SELECT 1 
        USE STOCK INDEX STOCK
       
	SELECT 2   
        USE STOCKP
	Muy_Listo()
        Form_1Q.Grid_1.Refresh

Return

*.............................................*
Function SelecDes()
*---------------------------------------------*
  
STOCK->(DbGoTo( Form_1Q.Grid_1.RecNo))

If STOCK->L = .T.
	Replace STOCK->L With .F.
Else
	Replace STOCK->L With .T.
EndIf

Return

*------------------------------------------------*
FUNCTION Muy_Listo()
*------------------------------------------------*      
       SELECT 1 
       USE STOCK 
       DO WHILE .NOT. EOF()
            REPLACE L WITH .F.
            SKIP + 1
       ENDDO
    Form_1Q.Grid_1.Refresh
Return
*---------------------------------------------*
Function  GetListSelect() 
*---------------------------------------------*
        CLOSE DATABASES
        USE STOCKP
        APPEND FROM STOCK FIELDS Ref , Producto , Tipo , Precio , CBarras , L FOR L <> .F.  

        CLOSE DATABASES    
        SELECT 1 
        USE STOCK 
        DO WHILE .NOT. EOF()
            REPLACE L WITH .F.
            SKIP + 1
        ENDDO

        SELECT 1 
        USE STOCK INDEX STOCK

        SELECT 2   
        USE STOCKP
 
     Form_1Q.Grid_2.Refresh
     Muy_Listo()
     Form_1Q.Grid_1.Refresh
Return

*---------------------------------------------*
Function Deleter()
*---------------------------------------------*
    CLOSE DATABASES
    SELECT 2
    USE STOCKP
 IF STOCKP->REF == 0
    MsgInfo('No hay Datos para Borrar','Info Delete')
    Muy_Listo()
    Form_1Q.Grid_1.Refresh
    Form_1Q.Grid_2.Refresh
    Return
 ENDIF

    CLOSE DATABASES
    SELECT 2
    USE STOCKP
    ZAP

   SELECT 1 
   USE STOCK  INDEX STOCK

   Muy_Listo()
   Form_1Q.Grid_1.Refresh
   Form_1Q.Grid_2.Refresh

Return
Andrés González López
Desde Guadalajara, Jalisco. México.
Post Reply