Modification at runtime, the widths of columns in a grid con

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AdrianSB
Posts: 17
Joined: Thu Feb 26, 2009 7:38 pm
Location: Argentina - Quilmes

Modification at runtime, the widths of columns in a grid con

Post by AdrianSB »

Hola a todos !!

Quisiera saber cómo modificar, en tiempo de ejecución, el tamaño de las columnas de un control GRID ( VER PASO [ 03 ] ).

//-[ 01 ] Vacío el contenido del control ------------------------------------------------
oWndConsultas.oGridResultados.DeleteAllItems

//-[ 02 ] Modifico el contenido de los encabezados ----------------------------------
For nCampo:=1 To Len(aEncabezados)
oWndConsultas.oGridResultados.Caption(nCampo) := aEncabezados[nCampo]
Next

//-[ 03 ] Modifico los anchos de las columnas ----------------------------------------
oWndConsultas.oGridResultados. :?: := aClone(aAnchos)

//-[ 04 ] Ingreso los nuevos registros --------------------------------------------------
For nRegistro:=1 To Len(aRegistros)
oWndConsultas.oGridResultados.AddItem(aClone(aRegistros[nRegistro]))
Next

//-[ 05 ] Actualizo la interfaz del control ----------------------------------------------
oWndConsultas.oGridResultados.Refresh()

Saludos !!

GOOGLE TRANSLATION

Hello everybody!

I would like to know how to modify, at runtime, the size of columns in a grid control (see step [03]).

/ / - [01] Empty the contents of the control --------------------------------------- ---------
oWndConsultas.oGridResultados.DeleteAllItems

/ / - [02] alters the content of headers ----------------------------------
For nCampo: = 1 To Len (aEncabezados)
oWndConsultas.oGridResultados.Caption (nCampo): = aEncabezados [nCampo]
Next

/ / - [03] modifies the widths of the columns -------------------------------------- --
oWndConsultas.oGridResultados. ::: = AClone (aAnchos)

/ / - [04] Entering new records ---------------------------------------- ----------
For nRegistro: = 1 To Len (aRegistros)
oWndConsultas.oGridResultados.AddItem (aClone (aRegistros [nRegistro]))
Next

/ / - [05] Updated control interface --------------------------------------- -------
oWndConsultas.oGridResultados.Refresh ()

Greetings!
User avatar
AdrianSB
Posts: 17
Joined: Thu Feb 26, 2009 7:38 pm
Location: Argentina - Quilmes

Re: Modification at runtime, the widths of columns in a grid con

Post by AdrianSB »

En hmg\source\h_grid.prg encontré 2 procedimientos creados para la modificación de la estructura de columnas de un control GRID:

Procedure _DeleteGridColumn ( cControlName , cParentForm , nColIndex )
Procedure _AddGridColumn ( cControlName , cParentForm , nColIndex , cCaption , nWidth , nJustify )

Unifiqué los pasos [ 02 ] y [ 03 ] para poder integrarlas a la necesidad buscada:

//-[ 02 y 03 ] Reemplazo las columnas existentes por nuevas ----------------------------------
For nCampo:=1 To Len(aEncabezados)
_DeleteGridColumn("oGridResultados","oWndConsultas",nCampo )
_AddGridColumn("oGridResultados","oWndConsultas",nCampo,aEncabezados[Campo],aAnchos[nCampo])
Next

No se si es la manera más eficiente de lograr el cambio de tamaño de las columnas, pero funciona...

Saludos !!

GOOGLE TRANSLATION

In HMG \ source \ h_grid.prg found 2 procedures established for changing the structure of columns in a grid control:

Procedure _DeleteGridColumn (cControlName, cParentForm, nColIndex)
Procedure _AddGridColumn (cControlName, cParentForm, nColIndex, cCaption, nWidth, nJustify)

Unify the steps [02] and [03] in order to integrate the need to search:

/ / - [02 and 03] Replacement of the existing columns with new ----------------------------------
For nCampo: = 1 To Len (aEncabezados)
_DeleteGridColumn (OGridResultados, oWndConsultas "nCampo)
_AddGridColumn (OGridResultados, oWndConsultas "nCampo, aEncabezados [Field], aAnchos [nCampo])
Next

If not the most efficient way of achieving change in size of the columns, but it works ...

Greetings!
Post Reply