To change ColumnWidth in Grid
Moderator: Rathinagiri
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
To change ColumnWidth in Grid
In HMG Extended I´ve used Form_1.Grid_1.ColumnWidth(1) := 1 for change ColumnWidth in Grid, buit I can not do this in HMG.
I also tried to remove column also in grid, but I am so fustrating...
There is someone someone knowing how to do it ?
I also tried to remove column also in grid, but I am so fustrating...
There is someone someone knowing how to do it ?
Last edited by Pablo César on Sat Dec 10, 2011 5:52 pm, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
To change ColumnWidth in Grid
To remove a column in Grid I already found it ! It's:
But I needing to resize a first column of grid to zero ou prox of it. Just to keep other functions working as "ON HEADCLICK" with MsgInfo('Header 1 Clicked !') for example. So if I remove first column the second column it is going to pass to be a first, then for index propose I will need to know with header really is.
Code: Select all
nCol:=1
i := GetControlIndex ( "Grid_1" , "Form_1" )
ListView_DeleteColumn ( _HMG_SYSDATA [3][i] , nCol )
Last edited by Pablo César on Sun Dec 11, 2011 4:50 pm, edited 2 times in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
To change ColumnWidth in Grid
Uhuyyyyy ! I got it !!!!
Seems very crazy to answer my own questions... hahahaha but I am really so happy, because I found the way, very simple:
nTam:=1
i := GetControlIndex ( "Grid_1" , "Form_1" )
// ListView_DeleteColumn ( _HMG_SYSDATA [3] , 1 )
LISTVIEW_SETCOLUMNWIDTH ( _HMG_SYSDATA [3] , 0 , nTam )
Please note number zero is the first element of array in language C. And as you can see I am using LISTVIEW_SETCOLUMNWIDTH function which works in C.
Now even clicking second header for index proposes after "hiding grid column", it's coming the right index column. This happen when starts program always with all columns to be displayed.
See captured screen to understand waht I am saying:

Seems very crazy to answer my own questions... hahahaha but I am really so happy, because I found the way, very simple:
nTam:=1
i := GetControlIndex ( "Grid_1" , "Form_1" )
// ListView_DeleteColumn ( _HMG_SYSDATA [3] , 1 )
LISTVIEW_SETCOLUMNWIDTH ( _HMG_SYSDATA [3] , 0 , nTam )
Please note number zero is the first element of array in language C. And as you can see I am using LISTVIEW_SETCOLUMNWIDTH function which works in C.
Now even clicking second header for index proposes after "hiding grid column", it's coming the right index column. This happen when starts program always with all columns to be displayed.
See captured screen to understand waht I am saying:
Last edited by Pablo César on Sun Dec 11, 2011 4:52 pm, edited 2 times in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Re: To change ColumnWidth in Grid
ON KEY F7 OF WMAIN ACTION {|| x:=oTP2.oBrowse:ColumnWidths(),x[2]:=800,oTP2.oBrowse:ColumnWidths(x),oTP2.oBrowse:Refresh() }Pablo César wrote:In HMG Extende it used to Form_1.Grid_1.ColumnWidth(1) := 1 for change ColumnWidth in Grid, buit I can not do this in HMG.
I also tried to remove column also in grid, but I am so fustrating...
There is someone someone knowing how to do it ?
ON KEY F6 OF WMAIN ACTION {|| x:=oTP2.oBrowse:ColumnHeaders(),x[2]:="TEST",oTP2.oBrowse:ColumnHeaders(x)}
Re: To change ColumnWidth in Grid
This is HMG.4JosK wrote:ON KEY F7 OF WMAIN ACTION {|| x:=oTP2.oBrowse:ColumnWidths(),x[2]:=800,oTP2.oBrowse:ColumnWidths(x),oTP2.oBrowse:Refresh() }Pablo César wrote:In HMG Extende it used to Form_1.Grid_1.ColumnWidth(1) := 1 for change ColumnWidth in Grid, buit I can not do this in HMG.
I also tried to remove column also in grid, but I am so fustrating...
There is someone someone knowing how to do it ?
ON KEY F6 OF WMAIN ACTION {|| x:=oTP2.oBrowse:ColumnHeaders(),x[2]:="TEST",oTP2.oBrowse:ColumnHeaders(x)}
I use virtualgrid (jkGrid is a copy of vitualgrid with small changes)
After Refresh the columnHeader i see the chance
This is my source:
Code: Select all
#include "hmg.ch"
#include "hbqtgui.ch"
#include "hbgtinfo.ch"
#include "std.ch"
SET DATE TO ANSI
SET EPOCH TO 1950 //KAN OOK CENTURY DOEN MAAR DAN 4 POSITIES..
SET CENTURY OFF
SET WRAP ON && ref 'menu to ...'
SET TALK OFF &&
SET BELL OFF &&
SET DELETED ON &&
SET SAFETY OFF &&
SET HEADING OFF &&
SET DELIMITERS OFF &&
SET SCOREBOARD OFF && geen Num, Ins, enz op lijn 0.
SET INTENSITY ON
SET DELIMITERS OFF
SET EXACT OFF
SET CURSOR OFF //KENT HMG NIET daar std.ch
SET DELETED ON && alleen btw bestand word direct gepackt ivm reccount()
SET EXCLUSIVE ON
setcancel(.f.)
FUNCTION Main()
//Public oTP1,oTP2
//Public oTLB //oTabpageLayoutBox -> local in oTP1
HbQt_ErrorSys()
wMain :=MaakMain("wMain")
oCW :=Widget():New("oCW",wMain)
oCW :CentralWidgetOF(wMain)
oLB :=LayoutBox():New("oLB",oCW,LAYOUT_TOPTOBOTTOM)
with object oTab:=Tab():New("oTab")
oTP1:=MaakTP1("oTP1",oTab)
oTP2:=MaakTP2("oTP2",oTab)
end
oLB:add(oTab)
oLB:SetLayout()
ON KEY F10 OF WMAIN ACTION {|| MSGSTOP("f10 binnen wmain")}
ON KEY F8 OF WMAIN ACTION {|| MSGSTOP( str( oTP1.oTLB:direction()))}
//0=l->r, 1=r-l, 2=t-b, 3=b-t, 4=form, 5=grid
ON KEY F9 OF WMAIN ACTION {|| if( (x:=oTP1.oTLB:Direction()) ==3, oTP1.oTLB:Directon(0), oTP1.oTLB:Direction(x+1) )}
//F9 heeft geen invloed op child olF onder oTLB
ON KEY F7 OF WMAIN ACTION {|| x:=oTP2.oBrowse:ColumnWidths(),x[2]:=800,oTP2.oBrowse:ColumnWidths(x),oTP2.oBrowse:Refresh() }
ON KEY F6 OF WMAIN ACTION {|| x:=oTP2.oBrowse:ColumnHeaders(),x[2]:="TEST",oTP2.oBrowse:ColumnHeaders(x)}
wMain:Activate()
Return NIL
***************************
STATIC FUNCTION MaakMain(c)
***************************
static o
if o==nil
o:= MAINWINDOW():New(c)
o:Title := "Maak Main Demo"
endif
return o
***************************************
STATIC FUNCTION MaakTab(c,oParent,nRow)
***************************************
local o
o:=Tab():New(c,oParent)
return o
***************************
FUNCTION MaakTP1(c,oParent)
***************************
local oTLB
static o
if o=Nil
//indien meerdere items op horizontaal is apart frame
// auto van 1/2 lines gaat niet lukken naar groot/klein scherm
o:=TabPage():New(c,oParent)
o:caption:="&Tabpage1"
oTLB:=LayoutBox():New("oTLB",o)
oTLB:direction(0)
//oLF:=Layoutform():New("oLF") //zonder parent over tab-kop/tekst
oLF:=Layoutform():New("oLF",oTLB)
oB1:=Button():New()
oB1:caption("Button1")
oT1:=TextBox():New()
oB2:=Button():New()
oB3:=MaakBtn("oB3")
oLF:add(oB1)
oLF:add(oT1)
oLF:add(oB2)
oLF:add(oB3)
oTLB:addlayout(oLF)
oTLB:setlayout()
// oTLB:insertstretch(2,33)
endif
return o
************
STATIC FUNCTION MaakBtn(c,oParent)
************
static o
o:=Button():New(c,oParent)
o:MaxWidth :=300
o:Caption := "Current Language"
o:OnClick := { || Bt1_OnClick() }
RETURN o
************
STATIC FUNCTION Bt1_OnClick()
************
MsgInfo( "Current Language is " + hb_ValToExp( HMGAPP():Language() ), "Language" )
RETURN NIL
***************************
FUNCTION MaakTP2(c,oParent)
local oTLB,oBrowse
static o
use c:\hmg.4\svn\samples\t\demo alias demo
go top
if o=Nil
o:=TabPage():New(c,oParent)
o:caption:="&RekSchema"
oTLB:=LayoutBox():New("oTLB",o,LAYOUT_TOPTOBOTTOM)
oBrowse:=MaakBrowse("oBrowse",o)
oTLB:add(oBrowse)
oTLB:setlayout()
endif
return o
**********************
function MaakBrowse(c,oParent)
**********************
static o
static bColor := { || IF ( ordkeyno()/2 == INT(ordkeyno()/2) , { 222,222,222 } , { 255,255,255 } ) }
static fColor := { || IF ( ordkeyno()/2 == INT(ordkeyno()/2) , { 255,0,0 } , { 0,0,255 } ) }
o:=jkGrid():New(c,oParent)
o:Row := 10
o:Col := 10
o:Width := 690
o:Height := 615
o:WorkArea := 'demo'
//o:OnChange :={||MsgInfo( "Andere cell/regel geselecteerd!" )}
//o:ONDBLClick :={||MsgInfo( "We gaan cell editten!" )}
* 'First','Last','Street','City','State','Zip','Hire Date','Married' ,'Age', Salary' , 'Notes'}
* '1,2,3,4,5,6Zip,7H,8'Married',9Age',10Salary' , 11Notes'}
//kreeg een error er daarom columnHeader toegevoegd
o:ColumnHeaders := { 'First' , 'Last' , 'Street' , 'City' , 'State' , 'Zip' , 'HireDate' , 'Married' , 'Age' , 'Salary' , 'Notes' }
o:ColumnFields := { 'First' , 'Last' , 'Street' , 'City' , 'State' , 'Zip' , 'HireDate' , 'Married' , 'Age' , 'Salary' , 'Notes' }
o:ColumnWidths := { 150 , 150 , 150 , 150 , 150 , 150 , 150 , 150 , 150 , 150 , 150 }
// ColumnJustify {GRID_JTFY_LEFT,GRID_JTFY_RIGHT,GRID_JTFY_LEFT,GRID_JTFY_LEFT,GRID_JTFY_LEFT,GRID_JTFY_RIGHT,GRID_JTFY_LEFT}
// brw_left etc is idem als grid_jtfy_left
o:ColumnJustify := { BRW_LEFT , BRW_RIGHT , BRW_CENTER , BRW_LEFT , BRW_RIGHT , BRW_CENTER , BRW_LEFT , BRW_RIGHT , BRW_CENTER , BRW_LEFT , BRW_RIGHT }
o:DynamicBackColor := { bColor , bColor , bColor , bColor , bColor , bColor , bColor , bColor , bColor , bColor , bColor }
o:DynamicForeColor := { fColor , fColor , fColor , fColor , fColor , fColor , fColor , fColor , fColor , fColor , fColor }
o:DynamicDisplay := { { || UPPER(First) } , NIL , NIL , NIL , NIL , NIL , NIL , { || IF(married,'Married','Not Married' ) } , NIL , NIL , NIL }
o:OnHeadClick := { { || MsgInfo( 'Click 1' ) } , , { || MsgInfo( 'Click 3' ) } , { || MsgInfo( 'Click 4' ) } , { || MsgInfo( 'Click 5' ) } , { || MsgInfo( 'Click 6' ) } , { || MsgInfo( 'Click 7' ) } , { || MsgInfo( '8' ) } , ,}
o:HeaderImages := { 'new.png' , 'open.png' , 'paste.png' , 'save.png' , 'new.png' , 'open.png' , 'paste.png' , 'save.png' , 'new.png' , 'open.png' , 'paste.png' }
//1.1= textbox,checkbox
//1.2=nummeric,date,character
//1.3=imputmask
//1.4=format alleen bij nummeric
// justify via andere array
//1="checkbox", caption=2of3,onchange=2of3 hij checkt op wel/niet block!?
//1="datepicker",2="UPDOWN" else updown=f
//1="spinner",2=RangeMin, 3=RangeMax
//1="combobox",2=items=array
o:ColumnControls :={{'TEXTBOX','CHARACTER'},;
{'TEXTBOX','CHARACTER'},;
{'TEXTBOX','CHARACTER','@K'},;
{"SPINNER",1,1000},;
{"COMBOBOX",{"January","February","March","April","May","June","July","August","September","October","November","December"}},;
{'TEXTBOX','CHARACTER',"@K"},;
{"DATEPICKER","UpDown"},;
{'CHECKBOX','Yes','No'},;
{'TEXTBOX','NUMERIC','99'},;
{'TEXTBOX','NUMERIC','999.99'},;
{'TEXTBOX','CHARACTER'};
}
o:MultiSelect := .F. //bij true = geen edit , alleen display
o:AllowEdit := .T. //alleen indien columnControls is ingevuld
o:Lines := .F.
o:VScrollBar := .F.
o:ColumnWhen := { { || UPPER(LEFT(first,1) ) == 'A' } ,;
, , , , , , , , , , , }
//msgstop wordt bij opbouwen scherm bij iedere regel getoond
//bij when en browse problem want werd bij iedere regel werd when uitgevoerd; ook bij opbouwen scherm
//er moet een block in staan want anders error na intoetsen key
//o:ColumnWhen := { { || UPPER(LEFT(first,1) ) == 'A' } , , , , , , , , , , }
//o:ColumnValid := { { || !EMPTY(memvar.demo.first) } , , , , , , , , , { || demo->salary > 100 } , }
o:ColumnValid := { { || !EMPTY(demo.first) } , , , , , , , , , { || demo->salary > 100 } , }
o:ValidMessages := { "First name can't be EMPTY" , , , , , , , , , "Salary mus be greater than 100" , }
x1:=len(o:ColumnControls())
x2:=len(o:ColumnValid())
x3:=len(o:ValidMessages())
if x1#x2.or.x1#x3
msgstop("x1="+str(x1) + " x2="+str(x2)+ " x3="+str(x3))
endif
return oRe: To change ColumnWidth in Grid
Code: Select all
ON KEY F7 OF WMAIN ACTION {|| x:=oTP2.oBrowse:ColumnWidths(),x[2]:=800,oTP2.oBrowse:ColumnWidths(x),oTP2.oBrowse:Refresh() }
ON KEY F6 OF WMAIN ACTION {|| x:=oTP2.oBrowse:ColumnHeaders(),x[2]:="TEST",oTP2.oBrowse:ColumnHeaders(x).oTP2.oBrowse:Refresh() }(in my example,see above, i have change the array 150,150,150 to 150,800,150 a now the layout is different and i don't see that after F7)
So we can:
- change refresh() is abstractgrid
- or change methode columnWidths in abstractgrid.prg (if !empty( or changed
- or add a methode to abstractgrid.prg of virtualgrid.prg SetColumnWidth(nCol,nWidth)
(basic->control->abstractgrid.prg->virtualgrid.prg
Methode setColumnWidth(nCol, nWidth) //in abstractGrid.prg
::aColumnWidths[nCol]:=nWidht
::oQtObject:setColumnWidth( nCol, ::aColumnWidths [nCol] )
Re: To change ColumnWidth in Grid
i work with virtualgrid.prg. With grid.prg there's maybe no problem if you enter F7 because there is a methode columnWidths(aValue) class grid
Re: To change ColumnWidth in Grid
i have change abstractgid.prg and now F7 works as expected.
Code: Select all
METHOD ColumnWidths( aValue ) CLASS ABSTRACTGRID
LOCAL i
IF Pcount() == 0
RETURN ::aColumnWidths
ELSEIF Pcount() == 1 .AND. hb_Isarray( aValue )
::aColumnWidths := aValue
//ADD
IF ::lCreated
FOR i := 0 to len( aValue ) - 1
::oQTObject:setColumnWidth( i,aValue[i+1] )
NEXT i
ENDIF
ENDIF
RETURN NILRe: To change ColumnWidth in Grid
He posted in a HMG.3 area....JosK wrote: This is HMG.4
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Re: To change ColumnWidth in Grid
Yes it should be for HMG 3, sorry I have nomentioned.
But any way I appreciate your help and I got already solutionated by:
i := GetControlIndex ( "Grid_1" , "Form_1" )
ListView_SetColumnWidth ( _HMG_SYSDATA [3] , 0 , 1 ) // for redimensioning
ListView_DeleteColumn ( _HMG_SYSDATA [3] , 1 ) // and for exclude colum
But this seems in HMG3. Which also be usefull to identify header when column is being excluded.JosK wrote:ON KEY F7 OF WMAIN ACTION {|| x:=oTP2.oBrowse:ColumnWidths(),x[2]:=800,oTP2.oBrowse:ColumnWidths(x),oTP2.oBrowse:Refresh() }
ON KEY F6 OF WMAIN ACTION {|| x:=oTP2.oBrowse:ColumnHeaders(),x[2]:="TEST",oTP2.oBrowse:ColumnHeaders(x)}
But any way I appreciate your help and I got already solutionated by:
i := GetControlIndex ( "Grid_1" , "Form_1" )
ListView_SetColumnWidth ( _HMG_SYSDATA [3] , 0 , 1 ) // for redimensioning
ListView_DeleteColumn ( _HMG_SYSDATA [3] , 1 ) // and for exclude colum
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein