//下拉列表事件 protected override void OnDropDown(EventArgs e) { if (IsMultiSelect) { list.Visible = !list.Visible; if (list.Visible) { list.Focus(); list.ItemHeight = this.ItemHeight; list.BorderStyle = BorderStyle.FixedSingle; list.Font = this.Font; list.Size = new Size(this.DropDownWidth, this.ItemHeight * (this.MaxDropDownItems - 1) - (int)this.ItemHeight / 2); list.Location = new Point(this.Left, this.Top + this.ItemHeight + 6); list.BeginUpdate(); if (this.DataSource != null) { list.DataSource = this.DataSource; list.DisplayMember = this.DisplayMember; list.ValueMember = this.ValueMember; } list.EndUpdate(); if (!this.Parent.Controls.Contains(list)) { this.Parent.Controls.Add(list); list.BringToFront(); } } } }
private void statDiagnosisDataGridView_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex == -1 && e.Button == MouseButtons.Right) { if (statDiagnosisDataGridView.Columns[e.ColumnIndex] == PFIO || statDiagnosisDataGridView.Columns[e.ColumnIndex] == DFIO || statDiagnosisDataGridView.Columns[e.ColumnIndex] == Texts) { int x = e.Location.X + statDiagnosisDataGridView.Location.X + statDiagnosisDataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Location.X; int y = e.Location.Y + statDiagnosisDataGridView.Location.Y + statDiagnosisDataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Location.Y; CheckedListBox list = listParam(ref x, y); if (statDiagnosisDataGridView.Columns[e.ColumnIndex] == DFIO) { list.Leave += new EventHandler(list_DisposedDOC); list.KeyDown += new KeyEventHandler(list_KeyDownDOC); list.GotFocus += new EventHandler(list_GotFocusDOC); } else if (statDiagnosisDataGridView.Columns[e.ColumnIndex] == PFIO) { list.Leave += new EventHandler(list_LostFocusPAT); list.KeyDown += new KeyEventHandler(list_KeyDownPAT); list.GotFocus += new EventHandler(list_GotFocusPAT); } else if (statDiagnosisDataGridView.Columns[e.ColumnIndex] == Texts) { list.Leave += new EventHandler(list_LostFocusTR); list.KeyDown += new KeyEventHandler(list_KeyDownTR); list.GotFocus += new EventHandler(list_GotFocusTR); } this.Controls.Add(list); list.BringToFront(); list.Focus(); } } }
protected override void OnDropDown(EventArgs e) { lst.Visible = !lst.Visible; if (!lst.Visible) { //this.Focus(); return; } lst.Focus(); lst.ItemHeight = this.ItemHeight; lst.BorderStyle = BorderStyle.FixedSingle; lst.Size = new Size(this.DropDownWidth, this.ItemHeight * (this.MaxDropDownItems - 1) - (int)this.ItemHeight / 2); lst.Location = new Point(this.Left, this.Top + this.ItemHeight + 6); lst.BeginUpdate(); lst.Items.Clear(); for (int i = 0; i < this.itemsList.Count; i++) { lst.Items.Add(this.itemsList[i]); if (this.checkedValues.ContainsKey(this.itemsList[i])) { lst.SetItemChecked(i, true); } } lst.EndUpdate(); if (!this.Parent.Controls.Contains(lst)) { this.Parent.Controls.Add(lst); } lst.BringToFront(); }
public ReportScreen(Dictionary<Sprint, List<Todo>> sprintTaskList, SortableBindingList<Project> projects) { InitializeComponent(); this.sprintTaskList = sprintTaskList; this.projects = projects; //this.checkedListBoxFilteredTasksInStatus.DataSource = tasks; //this.checkedListBoxFilteredTasksInStatus.DisplayMember = "ShortDescription"; splitContainer1.Panel2.Controls.Clear(); Button selectAllButton = new Button(); selectAllButton.Text = "Select All"; selectAllButton.Height = 29; selectAllButton.FlatStyle = FlatStyle.Flat; selectAllButton.Click += selectAllButton_Click; selectAllButton.Dock = DockStyle.Top; selectAllButton.ForeColor = Color.White; Button deselectAllButton = new Button(); deselectAllButton.Text = "Deselect All"; deselectAllButton.Height = 29; deselectAllButton.FlatStyle = FlatStyle.Flat; deselectAllButton.Click += deselectAllButton_Click; deselectAllButton.Dock = DockStyle.Top; deselectAllButton.ForeColor = Color.White; splitContainer1.Panel2.Controls.Add(selectAllButton); splitContainer1.Panel2.Controls.Add(deselectAllButton); foreach (KeyValuePair<Sprint, List<Todo>> st in sprintTaskList) { CheckedListBox checkedListBox = new CheckedListBox(); checkedListBox.BorderStyle = BorderStyle.None; checkedListBox.BackColor = BlackTheme.ColorDarkGray; checkedListBox.ForeColor = BlackTheme.ColorText; checkedListBox.Dock = DockStyle.Top; checkedListBox.Height = 300; checkedListBox.DataSource = st.Value; checkedListBox.Tag = st.Key; checkedListBox.DisplayMember = "ShortDescription"; Label sprintLabel = new Label(); sprintLabel.Text = st.Key.ShortDescription; sprintLabel.ForeColor = BlackTheme.ColorTextNotifyBlue; sprintLabel.Padding = new System.Windows.Forms.Padding(0, 10, 0, 5); sprintLabel.AutoSize = false; sprintLabel.Height = 40; sprintLabel.Dock = DockStyle.Top; splitContainer1.Panel2.Controls.Add(sprintLabel); sprintLabel.BringToFront(); splitContainer1.Panel2.Controls.Add(checkedListBox); checkedListBox.BringToFront(); } RenderSprintTodoList(sprintTaskList); BlackTheme.ApplyTheme(this); }
public CheckBoxForm(List <string> allItems, List <string> itemsChecked, string label, Icon icon, int buttonheight) { this.Text = label; Panel panel = new Panel(); panel.Height = buttonheight; this.Controls.Add(panel); checkers = new CheckedListBox(); this.Controls.Add(checkers); this.Icon = icon; checkers.Dock = DockStyle.Fill; panel.Dock = DockStyle.Bottom; Button ok = new Button(); ok.Text = Loc.Instance.GetString("OK"); ok.DialogResult = DialogResult.OK; Button cancel = new Button(); cancel.Text = Loc.Instance.GetString("Cancel"); cancel.DialogResult = DialogResult.Cancel; panel.Controls.Add(ok); panel.Controls.Add(cancel); ok.Dock = DockStyle.Left; cancel.Dock = DockStyle.Right; this.AcceptButton = ok; foreach (string ss in allItems) { checkers.Items.Add(ss); bool check = false; if (itemsChecked.Find(s => s == ss) != null) { check = true; } // grab last added item and set check state checkers.SetItemChecked(checkers.Items.Count - 1, check); } checkers.Sorted = true; checkers.BringToFront(); }
private void toolStripButtonFiltrPAT_Click(object sender, EventArgs e) { if (toolStripButtonFiltrPAT.Tag == null) { int x = toolStripFILTR.Location.X + toolStripButtonFiltrPAT.Bounds.Location.X; int y = toolStripFILTR.Location.Y + toolStripButtonFiltrPAT.Bounds.Location.Y + toolStripButtonFiltrPAT.Height; CheckedListBox list = listParam(ref x, y); toolStripButtonFiltrPAT.Tag = list; list.Leave += new EventHandler(list_LostFocusPAT); list.KeyDown += new KeyEventHandler(list_KeyDownPAT); list.GotFocus += new EventHandler(list_GotFocusPAT); this.Controls.Add(list); list.BringToFront(); list.Focus(); } else { statDiagnosisDataGridView.Focus(); } }
/// <summary> /// Gets the config panel for AddIns /// </summary> /// <returns> /// The config panel. /// </returns> public Panel GetConfigPanel() { // if panel made then leave it alone\ //February 27 2013 -- I removed this because it would not notice addins added // at runtime, which was one of the main points for this (i.e., once panel was open it never refreshed) // if (PanelWasMade == true) // return configPanel; PanelWasMade = true; configPanel = new Panel(); configPanel.BackColor = Color.Blue; checkers = new CheckedListBox(); checkers.Parent = configPanel; checkers.Dock = DockStyle.Fill; checkers.BringToFront(); BuildListOfAddins(); if (null == AddInsList) { lg.Instance.Line("Addins.GetConfigPanel", ProblemType.MESSAGE, "No AddIns discovered."); } //checkers.DataSource = AddInsList; //checkers.DisplayMember = "CalledFrom.MyMenuName"; //#STEP #1 : Load the previous preferences (go back into GetConfigPanel) List <string> myList = GetListOfInstalledPlugs(); /*List<string>Guids = new List<string>(); * * * if (myList != null && myList.Count > 0) { * * foreach (object[] o in myList) { * string GUIDOfAPlugIn = o [0].ToString (); * Guids.Add (GUIDOfAPlugIn); * } * }*/ foreach (MefAddIns.Extensibility.mef_IBase plug in AddInsList) { ListViewItem item = new ListViewItem(plug.CalledFrom.MyMenuName); item.Text = String.Format("{0} ({1}) ", plug.Name, plug.Version.ToString()); if (plug.IsCopy) { // a copy of this GUID was present item.Text = item.Text + Loc.Instance.GetString(" (COPY) "); } item.Tag = plug.CalledFrom; bool IsChecked = false; bool IsDisabled = false; if (plug.dependencyguid != Constants.BLANK) { IsDisabled = true; } bool IsVersionDisabled = false; if (plug.dependencymainapplicationversion != Constants.BLANK) { // NewMessage.Show(String.Format ("Comparing {0} with Application {1}",plug.dependencymainapplicationversion, Application.ProductVersion)); Version plugNeedsVersion = new Version(plug.dependencymainapplicationversion); Version appVersion = new Version(Application.ProductVersion); if (plugNeedsVersion > appVersion) { IsVersionDisabled = true; } } foreach (string guid in myList) { if (guid == plug.CalledFrom.GUID) { IsChecked = true; } if (IsDisabled == true) { // check to see if the GUID is enabled for my dependency if (guid == plug.dependencyguid) { IsDisabled = false; } } } // we do not add Disabled Items if (true != IsDisabled) { if (true != IsVersionDisabled) { if (plug.CalledFrom.IsANote) { item.Text = String.Format("{0} ({1})", item.Text, Loc.Instance.GetString("Deactivating requires application exit.")); } checkers.Items.Add(item, IsChecked); } else { NewMessage.Show(Loc.Instance.GetStringFmt("The Addin '{0}' was not added because it requires version '{1}' of the main application.", plug.Name, plug.dependencymainapplicationversion)); } } else { NewMessage.Show(Loc.Instance.GetStringFmt("The AddIn '{0}' was not added because it requires the AddIn '{1}' to be installed", plug.Name, plug.dependencyguid)); } } checkers.DisplayMember = "Text"; return(configPanel); }
/// <summary> /// 打开选项列表,刷新下来菜单 /// </summary> /// <param name="e"></param> protected override void OnDropDown(EventArgs e) { if (lst.Items.Count == 0) { // 假如数据还没有加载 // 那么加载. lst.BeginUpdate(); for (int i = 0; i < this.CheckAbleItemList.Count; i++) { lst.Items.Add(this.CheckAbleItemList[i]); } lst.EndUpdate(); lst.ItemHeight = this.ItemHeight; lst.BorderStyle = BorderStyle.FixedSingle; lst.Size = new Size(this.DropDownWidth, this.ItemHeight * (this.MaxDropDownItems - 1) - (int)this.ItemHeight / 2); lst.Location = new Point(this.Left, this.Top + this.ItemHeight + 6); this.Parent.Controls.Add(lst); // 加这句话的目的, 是为了避免 控件被别的控件挡住. lst.BringToFront(); } if (lstShowFlag == CheckedListBoxShowMode.Hide) { // 当前未显示,调整为显示. lst.Show(); lst.Focus(); lstShowFlag = CheckedListBoxShowMode.Show; } else if (lstShowFlag == CheckedListBoxShowMode.Show) { // 当前已显示,调整为不显示. lst.Hide(); lstShowFlag = CheckedListBoxShowMode.Hide; } else if (lstShowFlag == CheckedListBoxShowMode.LostFocus) { // 当前是 CheckedListBox 失去输入焦点. // 对于失去焦点的情况. // 需要作判断 // 因为 可能是点到其它的控件,而 CheckedListBox 失去输入焦点. // 也可能是 直接从 CheckedListBox 点到本控件. if (DateTime.Now.AddMilliseconds(-250) > lastLostFocusDateTime) { // 如果 CheckedListBox 失去焦点的时间 // 与本次点击下拉列表的时间 // 间隔超过 250 毫秒 // 认为是 经过了另外一个控件. // 现在点击回来了,需要显示. lst.Show(); lst.Focus(); lstShowFlag = CheckedListBoxShowMode.Show; } else { // 是直接从 CheckedListBox 失去焦点 // 然后再点击了 本 ComboBox 控件. lstShowFlag = CheckedListBoxShowMode.Hide; } } }