¿Cómo autoajusto un Grid en modo ejecución?

132 views
Skip to first unread message

Alejandro Garcia G.

unread,
Dec 12, 2016, 8:34:44 AM12/12/16
to Comunidad de Visual Foxpro en Español
Cordial saludo.

Tengo un formulario que utiliza una consulta con base en ciertos criterios, la consulta me puede dar N columnas distintas en cada caso que visualizo en una cuadricula (grid), tengo un pequeña rutina que me da las columnas que se necesitan para visualiarlas en la cuadricula sin embargo, no he logrado que toda ella se autoajuste al cambiar el número de dichas columnas hasta llegar a un maxímo por cuestion estetica dentro del formulario. ¿Esto se podra hacer?

Ejemplo: mi primera consulta me da 10 columnas a mostrar y me la muestra bien, la segunda consulta es de 6 columnas, y me las muestra bien pero el tamaño total de la cuadricula se me queda como si fueran 10 columnas dejando el resto de espacio vacio y esteticamente no me gusta como se ve.

Jairo Miranda

unread,
Dec 12, 2016, 9:18:38 AM12/12/16
to publicesvfoxpro
Control.Anchor [= nValue]

Return Value

nValue

Specifies a bit value that determines the anchor behavior of the control. The following table describes bit values you can set or add to produce values for nValue.

Position Bit value Bit number Conflicting values Description

Top Left

0

 

 

Anchors control to the top and left borders of the container and does not change the distance between the top and left borders. (Default)

Top Absolute

1

0

16, 512

Anchors control to top border of container and does not change the distance between the top border.

Left Absolute

2

1

32, 256

Anchors control to left border of container and does not change the distance between the left border.

Bottom Absolute

4

2

64, 512

Anchors control to bottom border of container and does not change the distance between the bottom border.

Right Absolute

8

3

128, 256

Anchors control to right border of container and does not change the distance between the right border.

Top Relative

16

4

1, 512

Anchors control to top border of container and maintains relative distance between the top border.

Left Relative

32

5

2, 256

Anchors control to left border of container and maintains relative distance between the left border.

Bottom Relative

64

6

4, 512

Anchors control to bottom border of container and maintains relative distance between the bottom border.

Right Relative

128

7

8, 256

Anchors control to right border of container and maintains relative distance between the right border.

Horizontal Fixed Size

256

8

2, 8, 32, 128

Anchors center of control relative to left and right borders but remains fixed in size.

Vertical Fixed Size

512

9

1, 4, 16, 64

Anchors center of control relative to top and bottom borders but remains fixed in size.

The following table describes examples of common settings for the Anchor property.

Control nValue Description

TextBox or EditBox

10

Resizes control horizontally as you resize it.

CommandButton

12

Displays a set of two controls, for example, OK and Cancel, in the lower right corner.

CommandButton

128 and 32

Centers two left and right command buttons.

CommandButton

260

Centers control on the bottom of a form.



jm

Fidel Charny

unread,
Dec 12, 2016, 9:22:12 AM12/12/16
to Comunidad de Visual Foxpro en Español
Generalmente tendrás un buen resultado con esta función, una vez determinado el ancho de cada columna.
Si la idea es que no haya desplazamiento horizontal del grid, permite que no se mueva la última columna.
PROCEDURE get_Grid_width
*-----------------------
LPARAMETERS toGrid

* toGrid: referencia al objeto Grid
* lnWidth = get_Grid_Width(thisform.grid1)

LOCAL lnWidth
,i

lnWidth
= IIF(toGRid.recordmark,10,1) ;
       
+ IIF(toGrid.deleteMark,6,0) ;
       
+ IIF(toGrid.scrollbars > 0,SYSMETRIC(5),4) ;
       
+ toGrid.Columncount -1 ;
       
+ 4

FOR i
= 1 TO toGrid.ColumnCount
    lnWidth
= m.lnWidth ;
       
+ toGrid.Columns(m.i).Width
NEXT

RETURN m
.lnWidth
ENDPROC

Alejandro Garcia G.

unread,
Dec 12, 2016, 12:09:33 PM12/12/16
to Comunidad de Visual Foxpro en Español
Creo que esta función me va a servir, tengo un detalle con mi anterior rutina para calcular el ancho de las columnas pero haicendo pruebas con este procedimiento en conjunto puedo llegar a una solución satisfactoria a lo que deseo.

graicas Fidel muy amable por la respuesta.
Reply all
Reply to author
Forward
0 new messages