public void DeleteSelectedEmptyCategory(ListBox listBoxAllCategories, ListBox listBoxThisCategory, TextBox textBoxCategoryName, GroupBox groupBoxCategory)//刪除category
 {
     if (CheckCategoryEmptied(listBoxThisCategory))
     {
         _model._categoryList.RemoveAt(SearchSelectedCategoryID(listBoxAllCategories.SelectedItem.ToString()) - 1);
         listBoxAllCategories.ClearSelected();
         LoadCategoryList(listBoxAllCategories);
         ClearAllCategoryTextBoxes(textBoxCategoryName, listBoxThisCategory);
         ChangeGroupBoxText(groupBoxCategory, ADD_NEW_CATEGORY);
     }
     else
     {
         for (int i = 0; i < listBoxThisCategory.Items.Count; i++)
         {
             _model._mealList[SearchSelectedMealID(listBoxThisCategory.Items[i].ToString()) - 1]._button.Visible = false;
             _model._lastDeletedMealButton = _model._mealList[SearchSelectedMealID(listBoxThisCategory.Items[i].ToString()) - 1]._button;
             _model._mealList.RemoveAt(SearchSelectedMealID(listBoxThisCategory.Items[i].ToString()) - 1);
         }
         _model._categoryList.RemoveAt(SearchSelectedCategoryID(listBoxAllCategories.SelectedItem.ToString()) - 1);
         listBoxAllCategories.ClearSelected();
         LoadCategoryList(listBoxAllCategories);
         ClearAllCategoryTextBoxes(textBoxCategoryName, listBoxThisCategory);
         ChangeGroupBoxText(groupBoxCategory, ADD_NEW_CATEGORY);
     }
 }
示例#2
0
        private void TextFieldChanged(object source, EventArgs args)
        {
            string prefix = itsTextBox.Text;

            if (prefix.Length == 0)
            {
                itsList.ClearSelected();
                return;
            }

            ListBox.ObjectCollection listItems = itsList.Items;
            bool found = false;

            for (int i = 0; found == false && i < listItems.Count; i++)
            {
                object o = listItems[i];
                string s = o.ToString();
                if (s.StartsWith(prefix))
                {
                    itsList.SetSelected(i, true);
                    found = true;
                }
            }

            if (!found)
            {
                itsList.ClearSelected();
            }
        }
示例#3
0
        private void buttonExtractData_Click(object sender, EventArgs evtArgs)
        {
            listBoxFiles.ClearSelected();
            this.Cursor = Cursors.WaitCursor;

            ExtractCoeffs();
            this.Cursor = Cursors.Default;
        }
示例#4
0
        private void RedrawBitmap()
        {
            Bitmap   bitmapa = new Bitmap(MaxWidth, MaxHeight);
            Graphics fl      = Graphics.FromImage(bitmapa);

            fl.Clear(Color.White);
            Bitmapa.Image = bitmapa;

            foreach (Element f in projectElements)
            {
                f.DrawImage(Graphics.FromImage(bitmapa));
            }
            Bitmapa.Refresh();

            if (Selected_Element is Furniture)
            {
                ListBox.DataSource = null;
                ListBox.DataSource = projectElements;
            }
            ListBox.Refresh();

            if (Selected_Element != null && Selected_Element.selected)
            {
                ListBox.SetSelected(GetIndex(Selected_Element), true);
            }
            else if (Selected_Element != null && !Selected_Element.selected)
            {
                ListBox.SetSelected(GetIndex(Selected_Element), false);
            }
            if (Selected_Element == null)
            {
                ListBox.ClearSelected();
            }
        }
示例#5
0
        private void ListBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            //used and modified from http://stackoverflow.com/questions/12929984/select-listbox-item-using-the-keyboard
            var newDate = DateTime.Now;
            var diff    = newDate - _lastKeyPress;

            if (diff.TotalSeconds >= 0.5)
            {
                _searchString = string.Empty;
            }
            _searchString += e.KeyChar;
            _listBox.ClearSelected();
            _listBox.SelectedIndex = _listBox.FindString(_searchString, 0);
            _lastKeyPress          = newDate;
            e.Handled = true;
        }
示例#6
0
        public MissionOption_CheckConfigFiles() : base()
        {
            InitializeComponent();
            listBox_ConfigList.ContextMenuStrip = new ContextMenuStrip();
            ToolStripItem linkStrip   = listBox_ConfigList.ContextMenuStrip.Items.Add("打开");
            ToolStripItem deleteStrip = listBox_ConfigList.ContextMenuStrip.Items.Add("删除");

            linkStrip.Click += delegate(object obj, EventArgs e)
            {
                if (listBox_ConfigList.SelectedItem != null)
                {
                    string selectedItem = listBox_ConfigList.SelectedItem.ToString();
                    Global.Instance.OpenURL(selectedItem);
                }
            };
            deleteStrip.Click += delegate(object obj, EventArgs e)
            {
                if (listBox_ConfigList.SelectedItem != null)
                {
                    ConfigFileList.Remove(listBox_ConfigList.SelectedItem.ToString());
                }
                RefreshList();
            };
            listBox_ConfigList.Click += delegate(object obj, EventArgs e)
            {
                int posY = listBox_ConfigList.PointToClient(MousePosition).Y;
                if (posY < 0 || posY > (listBox_ConfigList.Items.Count * listBox_ConfigList.ItemHeight))
                {
                    listBox_ConfigList.ClearSelected();
                }
            };
        }
示例#7
0
        internal void UnesiLek(TextBox txtImeLeka, TextBox txtKategorijaLeka, ListBox lboxBolesti)
        {
            if (txtKategorijaLeka.Text == "" || txtImeLeka.Text == "" || lboxBolesti.SelectedItems.Count == 0)
            {
                MessageBox.Show("Invalid input");
                return;
            }

            Medicine m = new Medicine()
            {
                Doctor           = MainController.Instance.Doctor,
                MedicineCategory = txtKategorijaLeka.Text,
                MedicineName     = txtImeLeka.Text,
                Illnesses        = lboxBolesti.SelectedItems.OfType <Illness>().ToList()
            };

            try
            {
                Response r = Communication.Instance.UnosLeka(m);
                txtImeLeka.Clear();
                txtKategorijaLeka.Clear();
                lboxBolesti.ClearSelected();
                MessageBox.Show("Medicine saved!");
            }
            catch (System.IO.IOException)
            {
                MessageBox.Show("Medicine not saved!");
                return;
            }
        }
示例#8
0
        private void DisplayLiveBox(DataTable results)
        {
            try
            {
                if (results.Rows.Count > 0)
                {
                    liveListBox.SuspendLayout();
                    liveListBox.DataSource    = null;
                    liveListBox.ValueMember   = currentLiveBoxConfig.ValueMember;
                    liveListBox.DisplayMember = currentLiveBoxConfig.DisplayMember;
                    liveListBox.DataSource    = results;
                    liveListBox.ClearSelected();
                    PosistionLiveBox();
                    liveListBox.Visible = true;
                    liveListBox.ResumeLayout();

                    if (previousSearchString != currentLiveBoxConfig.TargetTextBox.Text.Trim())
                    {
                        StartLiveSearch(currentLiveBoxConfig);
                        //if search string has changed since last completion, run again.
                    }
                }
                else
                {
                    liveListBox.Visible = false;
                }
            }
            catch
            {
                HideLiveBox();
            }
        }
示例#9
0
 /// <summary>
 /// 1. Kontrollerar så att dtpSlutDatum ej är mindre eller samma
 ///    som dtpStartDatum. Är den det sätts dtpSlutDatum automatiskt
 ///    till en dag senare än dtpStartDatum. Felmeddelande genereras
 ///    till feedbackfältet!
 /// 2. Om allt är OK så görs istället en sökning i databasen.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dtpSlutDatum_ValueChanged(object sender, EventArgs e)
 {
     if (_dtpSlutDatum.Value <= _dtpStartDatum.Value)
     {
         _dtpSlutDatum.Value = _dtpStartDatum.Value.AddHours(24);
         _tbFeedback.Text    = felSlutDatum;
     }
     else
     {
         _tbFeedback.Clear();   // rensar feedbackfältet
         _lbxLedare.DataSource  = null;
         _lbxGrupper.DataSource = null;
         sokledare();
         _lbxLedare.ClearSelected();
     }
 }
示例#10
0
 public void AddMessage(string m)
 {
     if (listboxReference.InvokeRequired)
     {
         listboxReference.Invoke(new DelegateAddMessage(AddMessage), m);
     }
     else
     {
         if (currentMessageIndex < maxMessages)
         {
             messages[currentMessageIndex] = m;
             listboxReference.Items.Add(m);
             ++currentMessageIndex;
         }
         else
         {
             for (int i = 0; i < (maxMessages - 1); ++i)
             {
                 messages[i] = messages[i + 1];
             }
             messages[maxMessages - 1] = m;
             listboxReference.Items.RemoveAt(0);
             listboxReference.Items.Add(m);
             listboxReference.Update();
         }
         listboxReference.SelectedIndex = listboxReference.Items.Count - 1;
         listboxReference.ClearSelected();
     }
 }
        private void limpiar()
        {
            foreach (var item in Controls)
            {
                if (item.GetType() == typeof(TextBox))
                {
                    TextBox c = (TextBox)item;
                    if (c.TabIndex != 49)
                    {
                        c.Text = "";
                    }
                }

                if (item is ListBox)
                {
                    ListBox l = (ListBox)item;

                    if (l.Enabled == true)
                    {
                        if (!(l.TabIndex >= 50 && l.TabIndex <= 52))
                        {
                            if (!(l.TabIndex >= 55 && l.TabIndex <= 56))
                            {
                                l.ClearSelected();
                            }
                        }
                    }
                }
            }
            txtTramite.Enabled = true;
            txtTramite.Select();
        }
示例#12
0
        private void listBoxPostes_MouseUp(object _s, MouseEventArgs e)
        {
            int     clickedIndex;
            ListBox sender = _s as ListBox;

            // the listbox is disabled or
            // if the pressed button is not the Right one, do nothing
            if (!sender.Enabled || e.Button != MouseButtons.Right)
            {
                return;
            }

            // if the user selected nothing yet or just one item,
            // find on what item he right-clicked, clear the selection
            // and set the clicked item as selected
            //
            // But, if the selection count is greater than 1, don't select
            // (the user probably wants to delete the whole selection).
            if (sender.SelectedIndices.Count < 2)
            {
                if ((clickedIndex = sender.IndexFromPoint(e.Location)) == ListBox.NoMatches)
                {
                    ShowAddMenu();
                    return;
                }
                sender.ClearSelected();
                sender.SelectedIndex = clickedIndex;
            }

            // open the menu
            ShowDeleteOrAddMenu();
        }
示例#13
0
 private void ClearAllSetOnClick(object sender, EventArgs eventArgs)
 {
     if (_ctgListBox != null)
     {
         _ctgListBox.ClearSelected();
     }
 }
示例#14
0
        public static void addRemoveFields(ListBox listBoxToRemove, ListBox listBoxToAdd)
        {
            if (listBoxToRemove == null || listBoxToAdd == null)
            {
                return;
            }

            if (listBoxToRemove.SelectedItems.Count < 1)
            {
                return;
            }
            else
            {
                List <string> selTexts = new List <string>();
                listBoxToAdd.ClearSelected();
                foreach (object obj in listBoxToRemove.SelectedItems)
                {
                    int nIndex = listBoxToAdd.Items.Add(obj);
                    listBoxToAdd.SetSelected(nIndex, true);
                    selTexts.Add(obj.ToString());
                }

                foreach (string selText in selTexts)
                {
                    listBoxToRemove.Items.Remove(selText);
                }

                listBoxToRemove.ClearSelected();
            }
        }
示例#15
0
        private void tsbSelect_Click(object sender, EventArgs e)
        {
            updating = true;
            lb.BeginUpdate();
            int currind = lb.TopIndex;

            switch (((ToolStripButton)sender).Name)
            {
            case "tsbSelectAll":
                for (int i = 0; i < lb.Items.Count; i++)
                {
                    lb.SetSelected(i, true);
                }
                break;

            case "tsbSelectNone":
                lb.ClearSelected();
                break;

            case "tsbInvert":
                for (int i = 0; i < lb.Items.Count; i++)
                {
                    lb.SetSelected(i, !lb.GetSelected(i));
                }
                break;
            }

            lb.TopIndex = currind;
            lb.EndUpdate();
            updating = false;
        }
示例#16
0
        public void SetListBox(string str)
        {
            try
            {
                //比较调用SetListBox方法的线程和创建ListBox1的线程是否同一个线程
                //如果不是,则listBox1的InvokeRequired为true
                if (listbox.InvokeRequired == true)
                {
                    //备注:windows应用程序中的每一个控件都对象都有一个InvokeRequired属性,用于检查是否
                    //需要通过调用Invoke方法完成其他线程对该控件的操作,如果该属性为true,说明是其他线程操作该控件,
                    //这时可以创建一个委托实例,然后调用控件对象的Invoke方法,并传入需要的参数完成相应操作,否则可以
                    //直接对该控件对象进行操作,从而保证了其他线程安全操作本线程中的控件。

                    //结果为true,则通过代理执行else中的代码,并传入需要的参数
                    listbox.Invoke(setListBoxCallback, str);
                }
                else
                {
                    //结果为false,直接执行
                    listbox.Items.Add(str);
                    listbox.SelectedIndex = listbox.Items.Count - 1;
                    listbox.ClearSelected();
                }
            }
            catch
            {
            }
        }
示例#17
0
 public void MoveSelectedItemsinListBoxtoOtherCheckedListBox(ListBox FromListBox, CheckedListBox ToListBox)
 {
     try
     {
         int intSelectedItems = FromListBox.SelectedItems.Count;
         int intToItemCount   = ToListBox.Items.Count;
         if (intSelectedItems > 0)
         {
             for (int i = 0; i < intSelectedItems; i++)
             {
                 ToListBox.Items.Add(FromListBox.SelectedItems[0]);
                 FromListBox.Items.Remove(FromListBox.SelectedItems[0]);
             }
             FromListBox.ClearSelected();
         }
         else
         {
             return;
         }
         ToListBox.SetItemChecked(intToItemCount, true);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception:" + ex.Message);
         return;
     }
 }
示例#18
0
        public void CleanUpPreviousSelections()
        {
            try
            {
                IEnumerator enumHits = listSearchHits.GetEnumerator();
                while (enumHits.MoveNext())
                {
                    IntPtr curHandle = (IntPtr)enumHits.Current;

                    TreeNode oldHit = TreeNode.FromHandle(classList, curHandle);

                    oldHit.BackColor = defaultBackColor;
                    oldHit.ForeColor = defaultForeColor;
                }

                //clean up the highlighted indices list
                listSearchHits.Clear();

                //classList.SelectedNode = null;

                selectedClassList.ClearSelected();

                descr.Text = string.Empty;
            }
            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
            }
        }
示例#19
0
        public static void ResetAllControls(Control form)
        {
            foreach (Control control in form.Controls)
            {
                if (control is TextBox)
                {
                    TextBox textBox = (TextBox)control;
                    textBox.Text = null;
                }

                if (control is ComboBox)
                {
                    ComboBox comboBox = (ComboBox)control;
                    if (comboBox.Items.Count > 0)
                    {
                        comboBox.SelectedIndex = 0;
                    }
                }

                if (control is CheckBox)
                {
                    CheckBox checkBox = (CheckBox)control;
                    checkBox.Checked = false;
                }

                if (control is ListBox)
                {
                    ListBox listBox = (ListBox)control;
                    listBox.ClearSelected();
                }
            }
        }
示例#20
0
 private void Uncheck(ListBox lb)
 {
     for (int i = 0; i < lb.Items.Count; i++)
     {
         lb.ClearSelected();
     }
 }
示例#21
0
        protected override void OnTextChanged(EventArgs e)
        {
            base.OnTextChanged(e);
            Point cp;

            GetCaretPos(out cp);
            List <string> lstTemp = new List <string>();
            string        last    = GetLastString(this.Text);

            listbox.SetBounds(cp.X + this.Left, cp.Y + this.Top + 20, 150, 50);
            var TempFilteredList = dictionary.Where(n => n.ToUpper().StartsWith(last.ToUpper())).Select(r => r);

            lstTemp = TempFilteredList.ToList <string>();
            if (lstTemp.Count != 0 && last != "")
            {
                listbox.DataSource = lstTemp;
                listbox.Visible    = true;
                listbox.ClearSelected();
                ChangeColor();
                //ChangeColor(last);
            }
            else
            {
                listbox.Visible = false;
            }
        }
示例#22
0
 private void SetListBoxItem(ListBox listbox, string text, ListBoxOperation operation)
 {
     if (listbox.InvokeRequired == true)
     {
         this.Invoke(listBoxCallback, listbox, text, operation);
     }
     else
     {
         if (operation == ListBoxOperation.AddItem)
         {
             if (listbox == listBoxAddress)
             {
                 if (listbox.Items.Contains(text) == false)
                 {
                     listbox.Items.Add(text);
                 }
             }
             else
             {
                 listbox.Items.Add(text);
             }
             listbox.SelectedIndex = listbox.Items.Count - 1;
             listbox.ClearSelected();
         }
         else if (operation == ListBoxOperation.RemoveItem)
         {
             listbox.Items.Remove(text);
         }
     }
 }
示例#23
0
        private void listBoxFriends_SelectedIndexChanged(object sender, EventArgs e)
        { // Invoke for both cases- match friends and all friends
            ListBox listbox = sender as ListBox;

            showFriendForm(listbox.SelectedItem as User);
            listbox.ClearSelected();
        }
示例#24
0
        private void listBox2_DragLeave(object sender, EventArgs e)
        {
            ListBox _lb = sender as ListBox;
            Point   _lbMousePoint = _lb.PointToClient(Control.MousePosition);
            int     pX = _lbMousePoint.X + 2, pY = _lbMousePoint.Y + 2;

            if (pX < 0 || pX >= _lb.Width || pY < 0 || pY >= _lb.Height)
            {
                try
                {
                    //Create new datasource
                    DataTable combDT = ((DataTable)_lb.DataSource).Copy();

                    //Remove
                    ((DataTable)_lb.DataSource).Rows.Remove(((DataRowView)_lb.SelectedItem).Row);

                    //Clear selection
                    _lb.ClearSelected();

                    if (_lb.Items.Count == 0 && !exportState)
                    {
                        radioButtonMove.Checked   = false;
                        radioButtonSelect.Checked = false;

                        buttonMoveSaves.Enabled   = false;
                        radioButtonMove.Enabled   = false;
                        radioButtonSelect.Enabled = false;
                    }
                }
                catch (Exception ex)
                {
                    string Msg = ex.Message;
                }
            }
        }
示例#25
0
        public static void ResetAllControls(Control form)
        {
            foreach (Control control in form.Controls)
            {
                if (control is TextBox)
                {
                    TextBox textBox = (TextBox)control;
                    textBox.Text = null;
                }

                if (control is ComboBox)
                {
                    ComboBox comboBox = (ComboBox)control;
                    if (comboBox.Items.Count > 0)
                    {
                        comboBox.SelectedIndex = 0;
                    }
                }

                if (control is CheckBox)
                {
                    CheckBox checkBox = (CheckBox)control;
                    checkBox.Checked = false;
                }

                if (control is ListBox)
                {
                    ListBox listBox = (ListBox)control;
                    listBox.ClearSelected();
                }

                if (control is ListView)
                {
                    ListView listBox = (ListView)control;
                    listBox.Clear();
                }

                if (control is CheckedListBox)
                {
                    CheckedListBox CheckedListBox = (CheckedListBox)control;
                    CheckedListBox.Items.Clear();
                }

                if (control is RichTextBox)
                {
                    RichTextBox RichTextBox1 = (RichTextBox)control;
                    if (RichTextBox1.Name == "richTextBox1")
                    {
                        RichTextBox1.Clear();
                    }

                    RichTextBox RichTextBox2 = (RichTextBox)control;
                    if (RichTextBox2.Name == "richTextBox2")
                    {
                        RichTextBox2.Clear();
                    }
                }
            }
        }
示例#26
0
        private void listBox3_DoubleClick(object sender, EventArgs e)
        {
            ListBox lb     = (ListBox)sender;
            int     number = int.Parse(lb.SelectedItem.ToString());

            listBoxInvalid.Items.Insert(0, number);
            lb.ClearSelected();
        }
示例#27
0
 public void Reload()
 {
     if (table != null)
     {
         table.Clear();
     }
     if (useAccess)
     {
         LoadA();
     }
     else
     {
         LoadS();
     }
     SetMember();
     LB.ClearSelected();
 }
示例#28
0
 private void LibraryQueueButton(ListBox listBox, List <string> list)
 {
     foreach (int selectedItem in listBox.SelectedIndices)
     {
         Player.AddQueue(list[selectedItem]);
     }
     listBox.ClearSelected();
 }
示例#29
0
 /*清除Cache中的选中项*/
 public void clearListBoxSelected()
 {
     for (int cacheNum = 0; cacheNum < 4; ++cacheNum)
     {
         string  cacheName   = "listBox" + cacheNum.ToString();
         ListBox refreashBox = (ListBox)this.Controls.Find(cacheName, true)[0];
         refreashBox.ClearSelected();
     }
 }
示例#30
0
        public static void limpiar(Control form)
        {
            foreach (Control control in form.Controls)
            {
                if (control is TextBox)
                {
                    TextBox textBox = (TextBox)control;
                    if (textBox.Enabled)
                    {
                        textBox.Text = null;
                    }
                }
                if (control is ComboBox)
                {
                    ComboBox comboBox = (ComboBox)control;
                    if (comboBox.Items.Count > 0)
                    {
                        comboBox.SelectedIndex = -1;
                    }
                }
                if (control is CheckBox)
                {
                    CheckBox checkBox = (CheckBox)control;
                    if (checkBox.ThreeState)
                    {
                        checkBox.CheckState = CheckState.Indeterminate;
                    }
                    else
                    {
                        checkBox.Checked = false;
                    }
                }
                if (control is ListBox)
                {
                    ListBox listBox = (ListBox)control;
                    listBox.ClearSelected();
                }
                if (control is DateTimePicker)
                {
                    DateTimePicker dateTimePicker = (DateTimePicker)control;
                    dateTimePicker.Value = ConfigManager.FechaSistema;

                    if (control.Name.Equals("dateTimePickerFilter"))
                    {
                        dateTimePicker.Checked = false;
                    }
                }
                if (control is CheckedListBox)
                {
                    CheckedListBox checkedListBox = (CheckedListBox)control;
                    foreach (int i in checkedListBox.CheckedIndices)
                    {
                        checkedListBox.SetItemCheckState(i, CheckState.Unchecked);
                    }
                }
            }
        }