How to add item in Grid Combo Box

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

How to add item in Grid Combo Box

Post 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
With best regards,
Sudip
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: How to add item in Grid Combo Box

Post 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


East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: How to add item in Grid Combo Box

Post 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
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: How to add item in Grid Combo Box

Post by sudip »

Rathi,

You are a magician :D It works excellent :D

With best regards.

Sudip
With best regards,
Sudip
Post Reply