[Gambas-user] Creatable Menu

richard terry rterry at ...1946...
Sun Nov 29 03:36:47 CET 2009


On Sunday 29 November 2009 12:31:35 Kadaitcha Man wrote:
> Menus are creatable according to http://gambasdoc.org/help/comp/gb.qt/menu
> 
> However I cannot see any methods anywhere that will allow me to add a
> menu item in code. For what I need to do, pre-defining the menus using
> the menu editor then hiding or showing the items is not practical.
> 
> Have I missed something?
> 
> ---------------------------------------------------------------------------
> --- Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>  30-Day trial. Simplify your report design, integration and deployment -
>  and focus on what you do best, core application coding. Discover what's
>  new with Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
Perhaps not so strangely I need religions in a medical program (for some 
reason my local hospital needs it on their ante-natal sheet, so here is some 
code for you: This data is keep in two tables > 1 view in the backend.
This code gives the picture shown.

Public Sub Religions_Menu_Create()
   '------------------------------------------------------
   'There is a 1 to many relationship between the religion
   'and subreligion but subreligion may be null
   'This creates a menu of religions, with sub-religions
   'as submenus
   '------------------------------------------------------
   Dim mnu As menu
   Dim member As Collection
   dim Religions as collection 
   Dim parent_menu As menu 
   Dim fk_last_religion As Integer
	'fetch view from backend
   Religions= modCommonDBI.Religions_Get()
  
   For Each member In Religions
      If fk_last_religion <> member!fk_religion Then
          fk_last_religion = member!fk_religion
          mnu = New Menu(mnuReligions) As "mnuReligions"
          parent_menu = mnu
         mnu.name = member!religion
         mnu.caption = member!religion
         mnu.tag = member!pk_view
      End If
      If Not IsNull(member!fk_lu_sub_religion) Then
            '-----------------------------
            'Add sub-religions to the menu
            '-----------------------------
            mnu = New Menu(parent_menu) As "mnuReligions"
            mnu.name = member!sub_religion
            mnu.caption = member!sub_religion
            mnu.tag = member!pk_view
      End If   
    Next
End
-------------- next part --------------
A non-text attachment was scrubbed...
Name: religion_menu.png
Type: image/png
Size: 24725 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20091129/ac658bce/attachment.png>


More information about the User mailing list