Page 1 of 1
How to add item in Grid Combo Box
Posted: Tue Feb 02, 2010 9:48 am
by sudip
Hello All,
Is there any way how can I add item in grid combo box. For example, suppose there is a one to many sale bill entry form, where I am using a grid for bill details entry (product, rate, qty etc.). During bill entry, user wants to add one product (using product master form), but I can't find any way how to add this product into the grid combo box item array.
Thanks in advance.
With best regards.
Sudip
Re: How to add item in Grid Combo Box
Posted: Tue Feb 02, 2010 10:30 am
by Rathinagiri
Hi Sudip,
Kindly use this 6 line small UDF hack.
Code: Select all
#include <minigui.ch>
Function Main
define window s at 0,0 width 600 height 400 main
define grid g
row 10
col 10
width 500
height 200
headers {"Name","City","Amount"}
widths {200,150,100}
allowedit .t.
COLUMNCONTROLS { {'TEXTBOX','CHARACTER'},{'COMBOBOX',{'CHENNAI','DELHI','KOLKATTA'}} , { 'TEXTBOX' ,'NUMERIC' ,"999999.99" } }
items {{"Giri",1,1000},{"Sudip",3,2000}}
end grid
define button b
row 230
col 10
width 200
caption "Add a new item in city"
action AddGridEditComboItem("g","s",2,"MUMBAI")
end button
end window
s.center
s.activate
Return
function AddGridEditComboItem(cGridName,cWindowName,nColIndex,cNewItem)
local i := 0
local aEditControls := {}
i := GetControlIndex ( cGridName , cWindowName )
aEditcontrols := _HMG_SYSDATA [ 40 ] [ i ] [ 2 ]
aadd(aEditControls [nColIndex] [2],cNewItem)
_HMG_SYSDATA [ 40 ] [ i ] [ 2 ] := aClone(aEditControls)
return nil
Re: How to add item in Grid Combo Box
Posted: Tue Feb 02, 2010 10:35 am
by Rathinagiri
If you want to alphabetically sort the items after adding the new item, use this.
Code: Select all
function AddGridEditComboItem(cGridName,cWindowName,nColIndex,cNewItem)
local i := 0
local aEditControls := {}
i := GetControlIndex ( cGridName , cWindowName )
aEditcontrols := _HMG_SYSDATA [ 40 ] [ i ] [ 2 ]
aadd(aEditControls [nColIndex] [2],cNewItem)
asort(aEditControls [nColIndex] [2])
_HMG_SYSDATA [ 40 ] [ i ] [ 2 ] := aClone(aEditControls)
return nil
Re: How to add item in Grid Combo Box
Posted: Tue Feb 02, 2010 11:52 am
by sudip
Rathi,
You are a magician

It works excellent
With best regards.
Sudip