Active Query Builder 2 .NET Edition reference
ValidateContextMenu Event
Example 



Is called before any of the component's context menus is shown.
Syntax
'Declaration
 
Public Event ValidateContextMenu As PopupMenuEventHandler
'Usage
 
Dim instance As QueryBuilder
Dim handler As PopupMenuEventHandler
 
AddHandler instance.ValidateContextMenu, handler
public event PopupMenuEventHandler ValidateContextMenu
public: __event PopupMenuEventHandler* ValidateContextMenu
Remarks

Allows to customize component's context menus.

The menu parameter refers to the ContextMenu object to be shown. Clear it's items to disable a menu.

The controlOwner parameter refers to the query object for which the context menu is called. The control parameter refers to the control representing this query object. The following combinations are possible:
- controlOwner is Link; control is LinkControl.
- controlOwner is DataSourceObject or DataSourceQuery; control is DataSourceControl.
- controlOwner is QueryColumnListItem; control is QueryColumnListControl.
- controlOwner is UnionSubQuery; control is DesignPane: design pane context menu.
- controlOwner is UnionSubQuery; control is UnionButton: context menu of the union button ("Q" button on the navigation bar).
- controlOwner is UnionSubQuery; control is UnionOperator: context menu of the union operator (union type symbol on the navigation bar).
- controlOwner is UnionGroup; control is LeftBracket: context menu of the left bracket ("(" symbol on the navigation bar).
- controlOwner is UnionGroup; control is RightBracket: context menu of the right bracket (")" symbol on the navigation bar).

Example
private void queryBuilder1_ValidateContextMenu(Control control, ControlOwner controlOwner, ContextMenuStrip menu)
{
    // Insert custom menu item to the top of any context menu
    menu.Items.Insert(0, new ToolStripMenuItem("Custom Item 1"));
    menu.Items.Insert(1, new ToolStripSeparator()); // separator
 
    if (controlOwner is Link) // Link context menu
    {
        // Add another item in the Link's menu
        menu.Items.Add(new ToolStripSeparator()); // separator
        menu.Items.Add("Custom Item 2");
 
        // control is LinkControl
    }
    else if (controlOwner is DataSourceObject) // Datasource context menu
    {
        // control is DataSourceControl
    }
    else if (controlOwner is UnionSubQuery)
    {
        if (control is DesignPane) // design pane context menu
        {
 
        }
        else if (control is UnionButton) // context menu of the union button ("Q" button on the navigation bar)
        {
 
        }
        else if (control is UnionOperator) // context menu of the union operator (union type symbol on the navigation bar)
        {
            // Delete all items from this menu.
            // The menu will not be shown.
            menu.Items.Clear();
        }
    }
    else if (controlOwner is UnionGroup)
    {
        if (control is LeftBracket) // context menu of the left bracket ("(" symbol on the navigation bar)
        {
 
        }
        else if (control is RightBracket) // context menu of the right bracket (")" symbol on the navigation bar)
        {
 
        }
    }
    else if (controlOwner is QueryColumnListItem) // context menu of the row of the query column list (grid)
    {
        // control is QueryColumnListControl
    }
}
See Also

Reference

QueryBuilder Class
QueryBuilder Members

 

 


© Copyright 2005-2012 ActiveDBSoft. All rights reserved.

Send Feedback