private void lbxActions_MouseDown(object sender, MouseEventArgs e) { int actionsCount = lbxActions.SelectedItems.Count + 1; FParent.ClosePopup(); DoUndoRedo(actionsCount); }
/// <summary> /// Processes SubItem Appointment selection /// </summary> /// <param name="sender">ButtonItem</param> /// <param name="e">EventArgs</param> void App_Click(object sender, EventArgs e) { ButtonItem bi = sender as ButtonItem; if (bi != null) { Appointment app = bi.Tag as Appointment; // Move this item to the selected appointment StartTime if (app != null) { MoveItem(app.StartTime); } } _Button.ClosePopup(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handle the configure menu item click. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private void HandleMenuItemClick(object sender, EventArgs e) { // Sometimes this has to be forced, so just do it all the // time since it's ignored when irrelevant. m_menu.ClosePopup(); // If the configure menu item was clicked on, then handle message dispatching. // All the other menu's on the popup are handled by the DNB manager click // event handler. if (sender is ButtonItem && ((ButtonItem)sender).Name == m_cfgMenuItem.Name) { if (m_cfgMenuItem.Tag is TagHelper) { string message = ((TagHelper)m_cfgMenuItem.Tag).Message; if (message != null) { m_mediator.SendMessage(message, Properties); } } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); Control tabControl = this.GetType().BaseType.GetField("tabControl", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.ExactBinding) .GetValue(this) as Control; barMain = new ContextMenuBar(); itemRoot = new ButtonItem("Root"); item1 = new ComboBoxItem("item1"); item1.Text = "显示比例"; ButtonItem btn1 = new ButtonItem("b1", "标准"); ButtonItem btn2 = new ButtonItem("b2", "适应"); ButtonItem btn3 = new ButtonItem("b3", "页面宽度"); item1.Items.AddRange(new BaseItem[] { btn1, btn2, btn3 }); item1.ComboWidth = 80; item1.DropDownStyle = ComboBoxStyle.DropDownList; item1.SelectedIndex = 0; item1.Click += (obj, args) => { switch (item1.SelectedIndex) { case 0: this.Zoom = 1f; break; case 1: this.ZoomWholePage(); break; case 2: this.ZoomPageWidth(); break; default: break; } }; item2 = new ComboBoxItem("item2"); item2.Text = "页面位置"; ButtonItem btn4 = new ButtonItem("b4", "前一页"); ButtonItem btn5 = new ButtonItem("b5", "后一页"); ButtonItem btn6 = new ButtonItem("b7", "首页"); ButtonItem btn7 = new ButtonItem("b8", "尾页"); item2.Items.AddRange(new BaseItem[] { btn4, btn5, btn6, btn7 }); item2.ComboWidth = 80; item2.DropDownStyle = ComboBoxStyle.DropDownList; item2.SelectedIndex = 0; item2.Click += (obj, args) => { switch (item2.SelectedIndex) { case 0: this.Prior(); break; case 1: this.Next(); break; case 2: this.First(); break; case 3: this.Last(); break; default: break; } }; item3 = new ButtonItem("item3"); item3.BeginGroup = true; item3.Text = "打印"; item3.Image = Res.GetImage(195); item3.Click += (obj, args) => { this.Print(); }; item4 = new ButtonItem("item4"); item4.Text = "打印当前页"; item4.Click += (obj, args) => { this.Report.PrintSettings.PageNumbers = this.PageNo.ToString(); this.Report.PrintSettings.PageRange = FastReport.PageRange.PageNumbers; this.Report.Print(); this.Report.PrintSettings.PageNumbers = ""; this.Report.PrintSettings.PageRange = FastReport.PageRange.All; }; item5 = new TextBoxItem("item5"); item5.Text = "页码范围"; item5.Click += (obj, args) => { try { this.Report.PrintSettings.PageNumbers = item5.ControlText; this.Report.PrintSettings.PageRange = FastReport.PageRange.PageNumbers; this.Report.Print(); this.Report.PrintSettings.PageNumbers = ""; this.Report.PrintSettings.PageRange = FastReport.PageRange.All; } catch { MessageBoxEx.Show("输入的页码范围无效,请核对后重试", "提示"); } }; itemRoot.SubItems.AddRange(new BaseItem[] { item1, item2, item3, item4, item5 }); barMain.SetContextMenuEx(tabControl, itemRoot); this.Controls.Add(barMain); tabControl.Controls[0].MouseDown += (obj, args) => { itemRoot.ClosePopup(); }; //tabControl.Controls[0].LostFocus += (obj, args) => //{ // itemRoot.ClosePopup(); //}; }