Spread WPF 14
GrapeCity.Windows.SpreadSheet.UI Namespace / ToolbarDropDown Class / ToolbarDropDown Constructor
Example


In This Topic
    ToolbarDropDown Constructor
    In This Topic
    Initializes a new instance of the ToolbarDropDown class.
    Syntax
    'Declaration
     
    Public Function New()
    'Usage
     
    Dim instance As New ToolbarDropDown()
    public ToolbarDropDown()
    Example
    This example adds a drop-down menu item.
    private GrapeCity.Windows.SpreadSheet.UI.TouchToolbar _toolbar;
          
            public MainWindow()
            {
                InitializeComponent();
                this.InitializeTouchStrip();
            }
    
            void autoFill_Click(object sender, EventArgs e)
            {
                var activeView = this.GcSpreadSheet1.View;
                if (activeView != null)
                {
                    activeView.ShowAutoFillIndicator();
                }
            }
    
            private void InitializeTouchStrip()
            {
                _toolbar = GrapeCity.Windows.SpreadSheet.UI.TouchToolbarFactory.CreateCutCopyPasteToolBar(this.GcSpreadSheet1.View);
                foreach (var item in _toolbar.ToolbarItems)
                {
                    var toolbarButton = item as GrapeCity.Windows.SpreadSheet.UI.ToolbarButton;
                    if (toolbarButton != null && toolbarButton.Title == "Cut")
                    {
                        toolbarButton.Visibility = System.Windows.Visibility.Collapsed;
                        break;
                    }
                }
                var separator1 = new GrapeCity.Windows.SpreadSheet.UI.ToolbarSeparator();
                _toolbar.ToolbarItems.Add(separator1);
                var autoFillButton = GrapeCity.Windows.SpreadSheet.UI.TouchToolbarFactory.CreateDragFillButton();
                _toolbar.ToolbarItems.Add(autoFillButton);
                var separator2 = new GrapeCity.Windows.SpreadSheet.UI.ToolbarSeparator();
                _toolbar.ToolbarItems.Add(separator2);
                var toolbarDropdown = new GrapeCity.Windows.SpreadSheet.UI.ToolbarDropDown();
                var menu = new ContextMenu();
                menu.Items.Add("Item1");
                toolbarDropdown.Menu = menu;
                _toolbar.ToolbarItems.Add(toolbarDropdown);
            }
    
            private void GcSpreadSheet1_TouchToolbarOpening(object sender, GrapeCity.Windows.SpreadSheet.UI.TouchToolbarOpeningEventArgs e)
            {
                e.Handled = true;
                _toolbar.Show(e.X - 100, e.Y - 100);          
            }
    Private _toolbar As GrapeCity.Windows.SpreadSheet.UI.TouchToolbar
        Public Sub New()
            InitializeComponent()
            Me.InitializeTouchStrip()
        End Sub
    
        Private Sub GcSpreadSheet1_TouchToolbarOpening(sender As Object, e As GrapeCity.Windows.SpreadSheet.UI.TouchToolbarOpeningEventArgs) Handles GcSpreadSheet1.TouchToolbarOpening
            e.Handled = True
            _toolbar.Show(e.X - 100, e.Y - 100)
        End Sub
    
        Private Sub autoFill_Click(sender As Object, e As EventArgs)
            Dim activeView = Me.GcSpreadSheet1.View
            If activeView IsNot Nothing Then
                activeView.ShowAutoFillIndicator()
            End If
        End Sub
    
        Private Sub InitializeTouchStrip()
            _toolbar = GrapeCity.Windows.SpreadSheet.UI.TouchToolbarFactory.CreateCutCopyPasteToolBar(Me.GcSpreadSheet1.View)
            For Each item In _toolbar.ToolbarItems
                Dim toolbarButton = TryCast(item, GrapeCity.Windows.SpreadSheet.UI.ToolbarButton)
                If toolbarButton IsNot Nothing AndAlso toolbarButton.Title = "Cut" Then
                    toolbarButton.Visibility = System.Windows.Visibility.Collapsed
                    Exit For
                End If
            Next
            Dim separator1 = New GrapeCity.Windows.SpreadSheet.UI.ToolbarSeparator()
            _toolbar.ToolbarItems.Add(separator1)
            Dim autoFillButton = GrapeCity.Windows.SpreadSheet.UI.TouchToolbarFactory.CreateDragFillButton()
            _toolbar.ToolbarItems.Add(autoFillButton)
            Dim separator2 = New GrapeCity.Windows.SpreadSheet.UI.ToolbarSeparator()
            _toolbar.ToolbarItems.Add(separator2)
            Dim toolbarDropdown = New GrapeCity.Windows.SpreadSheet.UI.ToolbarDropDown()
            Dim menu = New GrapeCity.Windows.SpreadSheet.UI.ContextMenu()
            menu.Items.Add("Item1")
            toolbarDropdown.Menu = menu
            _toolbar.ToolbarItems.Add(toolbarDropdown)
        End Sub
    See Also