Different ComboBox at Grid
Moderator: Rathinagiri
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Different ComboBox at Grid
Hi all,
This is the tip to overcome the limitation of only one Combobox per column and do different inside the Grid with COLUMNCONTROLS:
I hope you like it.
This is the tip to overcome the limitation of only one Combobox per column and do different inside the Grid with COLUMNCONTROLS:
I hope you like it.
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: Different ComboBox at Grid
Thank you Pablo for sharing
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Different ComboBox at Grid
Really nice trick Pablo.
At this juncture I wish to share another trick (which Claudio taught me) to align differently in a column. I am using this trick for a grid to show like a property sheet.
At this juncture I wish to share another trick (which Claudio taught me) to align differently in a column. I am using this trick for a grid to show like a property sheet.
Code: Select all
#include "hmg.ch"
Function Main
PRIVATE aRows [20][3]
aRows [1] := { 113.12, date(), '1', 1, .t. }
aRows [2] := { 123.12, date(), '2', 2, .f. }
aRows [3] := { 133.12, date(), '3', 3, .t. }
aRows [4] := { 143.12, date(), "A", 4, .f. }
aRows [5] := { 153.12, date(), '2', 5, .t. }
aRows [6] := { 163.12, date(), '3', 6, .f. }
aRows [7] := { 173.12, date(), "B", 7, .t. }
aRows [8] := { 183.12, date(), '2', 8, .f. }
aRows [9] := { 193.12, date(), "A", 9, .t. }
aRows [10] := { 113.12, date(), '1', 10, .f. }
aRows [11] := { 123.12, date(), '2', 11, .t. }
aRows [12] := { 133.12, date(), "C", 12, .f. }
aRows [13] := { 143.12, date(), '1', 13, .t. }
aRows [14] := { 153.12, date(), '2', 14, .f. }
aRows [15] := { 163.12, date(), '3', 15, .t. }
aRows [16] := { 173.12, date(), '1', 16, .f. }
aRows [17] := { 183.12, date(), "B", 17, .t. }
aRows [18] := { 193.12, date(), '3', 18, .f. }
aRows [19] := { 113.12, date(), '1', 19, .t. }
aRows [20] := { 123.12, date(), '2', 20, .f. }
for i := 1 to 20
if ascan( {'A','B','C'} , aRows[ i, 3 ] ) == 0
aRows[ i, 3 ] := rightalignedtext( aRows[ i, 3 ], 120, 'Arial', 9, .f. )
endif
next i
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 600 ;
HEIGHT 430 ;
TITLE 'Mixed Data Type Grid Test' ;
MAIN NOSIZE NOMAXIMIZE
DEFINE STATUSBAR FONT "Courier New" SIZE 9
STATUSITEM PadC("Try by clicking at 3rd column and see the ComboBox items",84)
END STATUSBAR
@ 10,10 GRID Grid_1 ;
WIDTH 576 ;
HEIGHT 330 ;
HEADERS {'Column 1','Column 2','Column 3','Column 4','Column 5'} ;
WIDTHS {120,120,120,120,70} ;
ITEMS aRows ;
EDIT ;
JUSTIFY { GRID_JTFY_RIGHT,GRID_JTFY_CENTER,GRID_JTFY_LEFT,GRID_JTFY_RIGHT, GRID_JTFY_LEFT } ;
COLUMNCONTROLS { {'TEXTBOX','NUMERIC','$ 999,999.99'} , {'DATEPICKER','DROPDOWN'} , {'TEXTBOX'}, { 'SPINNER' , 1 , 20 } , { 'CHECKBOX' , 'Yes' , 'No' } } ;
COLUMNVALID {{ || .T.},{ || .T.},{ || Valid3()},{ || .T.},{ || .T.}} ;
CELLNAVIGATION
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return Nil
Function Valid3()
LOCAL lRet:=.F.
LOCAL c:=This.CellColFocused
LOCAL r:=This.CellRowFocused
LOCAL xValue:=This.CellValue
If !Empty(This.CellValue)
lRet:=.T.
If ascan( {'A','B','C'}, xValue ) == 0
This.CellValue := rightalignedtext( xValue, 120, 'Arial', 9, .f. )
endif
Endif
Return lRet
function rightalignedtext( cData, nWidth, cFont, nSize, lBold )
local hDC, BTstruct
local nTextSize := 0
local aTextData := {}
local nType := BT_TEXT_OPAQUE
nWidth := nWidth - 15
hDC := BT_CreateDC ( , BT_HDC_DESKTOP, @BTstruct)
if lBold
nType := BT_TEXT_BOLD
endif
do while nTextSize < nWidth
aTextData := BT_DrawTextSize ( hDC, cData, cFont, nSize, nType )
nTextSize := aTextData[ 1 ]
if nTextSize < nWidth
cData := ' ' + cData
endif
enddo
BT_DeleteDC (BTstruct)
return cData
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- serge_girard
- Posts: 3169
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Different ComboBox at Grid
Thanks for sharing Pablo !
Serge
Serge
There's nothing you can do that can't be done...
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Different ComboBox at Grid
Very nice too Rathi !
Amazing results we can get thru BT_DrawTextSize. I loved RightAlignedText function. Thank you for sharing !
Bos Taurus is a real jewel that Claudio has given us.
Amazing results we can get thru BT_DrawTextSize. I loved RightAlignedText function. Thank you for sharing !
Bos Taurus is a real jewel that Claudio has given us.
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
Different ComboBox at Grid
As it has done with ComboBox, other controls can be changed on the fly:
Now is changing from TextBox to Spinner or TextBox for Character (I think in right aligned).
Now is changing from TextBox to Spinner or TextBox for Character (I think in right aligned).
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
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Different ComboBox at Grid
Good. If we can standardize and do it as "DYNAMICCOLUMNCONTROL" according to some conditions that will complete the circle.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Different ComboBox at Grid
Same demo as the previous one but with some differenciated COLUMNWHEN followed of different COLUMNCONTROLS type.
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
- serge_girard
- Posts: 3169
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Different ComboBox at Grid
Thanks Pablo, great job !
Serge
Serge
There's nothing you can do that can't be done...