Ian Lucas
2014-02-18T11:14:52Z
Hi,

I would like to be able (in VBA) to trigger a Replace function for text in a column by right-clicking on the column header.

Is it possible to extend the built-in context menu to enable me to add in extra functions such as this?

It wasn't possible 2 years ago according to the forum, but is it now?

Alternatively, is it possible to create a custom context menu including the items that the built-in column header context menu already has (Sort Ascending, Sort Descending, Group by this Column, Remove Grouping), plus any items that I might want to add? I wouldn't want to lose the existing functions. I would also prefer not to have to invent my own code for the existing functions when you have the code already.

Best wishes (I am enjoying iGrid),

Ian Lucas
Igor/10Tec
2014-02-18T15:55:04Z
Unfortunately, we never thought about extending iGrid this way, i.e. having a special event or something like that to make it possible to add custom context menu items to the existing ones.

As for exploiting the header context menu functionality, you can do that enough easily using the existing public members of iGrid. Below is the corresponding source code snippet used to process the menu items:

Select Case wParamLoWord

Case WM_MENUBASE + MENUHEADER_SORTASC

   DoDefaultSort m_lHeaderRightClickColIndex, 1, igSortAsc

Case WM_MENUBASE + MENUHEADER_SORTDESC

   DoDefaultSort m_lHeaderRightClickColIndex, 1, igSortDesc

Case WM_MENUBASE + MENUHEADER_GROUPBYCOL
   Set m_cGroup = m_cGroupCur.Clone()
   m_cGroup.AddItem m_lHeaderRightClickColIndex, _
      m_tCols(m_lHeaderRightClickColPos).eSortOrderDefault, _
      m_tCols(m_lHeaderRightClickColPos).eSortType
   Group
Case WM_MENUBASE + MENUHEADER_UNGROUPBYCOL

   Dim lGrpColIdx As Long
   lGrpColIdx = m_cGroupCur.frlFindColIndex(m_lHeaderRightClickColIndex)
   If lGrpColIdx <> 0 Then
      Set m_cGroup = m_cGroupCur.Clone()
      m_cGroup.RemoveItem lGrpColIdx
      Group ' may also Ungroup if m_cGroup.ColCount become equal 0
   End If

Case WM_MENUBASE + MENUHEADER_REMOVEGROUPING

   Ungroup

End Select

DoDefaultSort, Group and Ungroup are iGrid methods. m_cGroupCur is in fact the current GroupObject.

Sure, if you have any troubles with interpreting this code, feel free to contact us for more help.
Ian Lucas
2014-02-19T00:12:02Z
Thanks Igor - much appreciated.

I should be fine using Igrid's Group, Ungroup and DoDefaultSort methods in a custom context menu, then adding in my extra context menu function(s). I should have checked the Help file more carefully before writing.
Igor/10Tec
2016-01-29T10:21:39Z
The ability to add custom items to the built-in context menus or completely redefine them was implemented in iGrid v6.