Select() public method

public Select ( int start, int length ) : void
start int
length int
return void
        private void textEmp_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            switch (e.KeyData)
            {
            case Keys.Up:
                if (comboBoxEmp.DroppedDown)
                {
                    textEmp.Leave -= new EventHandler(textEmp_Leave);
                    comboBoxEmp.Select();
                    comboBoxEmp.SelectedItem = comboBoxEmp.Items[comboBoxEmp.Items.Count - 1];
                    comboBoxEmp.FindForm().Cursor = Cursors.Default;
                    textEmp.Leave += new EventHandler(textEmp_Leave);
                }
                break;

            case Keys.Down:
                if (comboBoxEmp.DroppedDown)
                {
                    textEmp.Leave -= new EventHandler(textEmp_Leave);
                    comboBoxEmp.Select();
                    comboBoxEmp.SelectedItem = comboBoxEmp.Items[0];
                    comboBoxEmp.FindForm().Cursor = Cursors.Default;
                    textEmp.Leave += new EventHandler(textEmp_Leave);
                }
                break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Called when the user has typed in a query but has not hit enter before the timeout, so we should
        /// show a dropdown list of other suggestions.
        /// </summary>
        /// <param name="source">unused</param>
        /// <param name="e">unused</param>
        public void onTimer(Object source, ElapsedEventArgs e)
        {
            if (listBox.Text == "")
            {
                return;
            }
            delayTimer.Stop();
            if (this.Visible != true)
            {
                return;
            }
            updateFields(listBox.Text);

            if (currentMatches.Count <= 1)
            {
                return;
            }

            listBox.Items.Clear();

            listBox.BeginUpdate();
            for (int i = 0; i < currentMatches.Count; i++)
            {
                listBox.Items.Insert(i, currentMatches[i]);
            }

            listBox.EndUpdate();

            listBox.DroppedDown = true;
            listBox.Select(listBox.Text.Length, 0);
        }
Beispiel #3
0
 private void LoadPrinters()
 {
     // Load all available printers
     foreach (String printer in
              PrinterSettings.InstalledPrinters)
     {
         printersList.Items.Add(printer.ToString());
     }
     printersList.Select(0, 1);
 }
Beispiel #4
0
		[Test] // bug 660294
		public void TestNullSelectedText ()
		{
			ComboBox comboBox = new ComboBox ();
			string text = "abc";
			comboBox.Items.Add (text);
			comboBox.SelectedIndex = 0;
			comboBox.Select (0, text.Length);
			comboBox.SelectedText = null;

			Assert.AreEqual (String.Empty, comboBox.SelectedText);
		}
Beispiel #5
0
        private void serverList_TextChanged(object sender, System.EventArgs e)
        {
            string txt = serverList.Text;

            if ((serverList.SelectedItem is Custom_SE || serverList.SelectedItem is LoginCFG_SE) && txt != (serverList.SelectedItem).ToString())
            {
                port.Text = "";
                serverList.BeginUpdate();
                serverList.SelectedIndex = -1;
                serverList.Text          = txt;
                serverList.Select(txt.Length, 0);
                serverList.EndUpdate();
            }
        }
Beispiel #6
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            numericUpDown1.Value = 10;

            // Create InstalledFontCollection object
            InstalledFontCollection
                sysFontCollection = new InstalledFontCollection();

            // Get the array of FontFamily objects.
            FontFamily[] fontFamilies = sysFontCollection.Families;
            // Read all font familes and add to the combo box
            for (int i = 0; i < fontFamilies.Length; ++i)
            {
                comboBox1.Items.Add(fontFamilies[i].Name);
            }
            comboBox1.Select(0, 20);
        }
Beispiel #7
0
        private void AddNew_tblCategory1(System.Windows.Forms.ComboBox CurrentCombo)
        {
            System.Data.SqlTypes.SqlInt32 NewPrimaryKey;

            OlymarsDemo.Windows.Forms.WinForm_tblCategory MyForm = new OlymarsDemo.Windows.Forms.WinForm_tblCategory();
            MyForm.AddNewRecord(this, "Add a new tblCategory", ConnectionString);

            if (MyForm.DialogResult == DialogResult.OK)
            {
                if (!MyForm.ErrorHasOccured)
                {
                    NewPrimaryKey = ((OlymarsDemo.DataClasses.Parameters.spI_tblCategory)MyForm.Parameter).Param_Cat_LngID;
                    Refresh_Pro_LngCategoryID();
                    CurrentCombo.SelectedValue = NewPrimaryKey.Value;
                }

                MyForm.Dispose();
                CurrentCombo.Select();
            }
        }
        private void AddNew_Customers1(System.Windows.Forms.ComboBox CurrentCombo)
        {
            System.Data.SqlTypes.SqlInt32 NewPrimaryKey;

            Bob.Windows.Forms.WinForm_Customers MyForm = new Bob.Windows.Forms.WinForm_Customers();
            MyForm.AddNewRecord(this, "Add a new Customers", ConnectionString);

            if (MyForm.DialogResult == DialogResult.OK)
            {
                if (!MyForm.ErrorHasOccured)
                {
                    NewPrimaryKey = ((Bob.DataClasses.Parameters.spI_Customers)MyForm.Parameter).Param_CustomerID;
                    Refresh_CustomerId();
                    CurrentCombo.SelectedValue = NewPrimaryKey.Value;
                }

                MyForm.Dispose();
                CurrentCombo.Select();
            }
        }
Beispiel #9
0
        private void AddNew_tblOrder1(System.Windows.Forms.ComboBox CurrentCombo)
        {
            System.Data.SqlTypes.SqlGuid NewPrimaryKey;

            OlymarsDemo.Windows.Forms.WinForm_tblOrder MyForm = new OlymarsDemo.Windows.Forms.WinForm_tblOrder();
            MyForm.AddNewRecord(this, "Add a new tblOrder", ConnectionString);

            if (MyForm.DialogResult == DialogResult.OK)
            {
                if (!MyForm.ErrorHasOccured)
                {
                    NewPrimaryKey = ((OlymarsDemo.DataClasses.Parameters.spI_tblOrder)MyForm.Parameter).Param_Ord_GuidID;
                    Refresh_Oit_GuidOrderID();
                    CurrentCombo.SelectedValue = NewPrimaryKey.Value;
                }

                MyForm.Dispose();
                CurrentCombo.Select();
            }
        }
        private void CreateManualFileEntryControl(object sender, EventArgs e)
        {
            if (_fileCombo != null &&_fileCombo.Visible)
            {
                _fileCombo.Visible = false;
                Controls.Remove(_fileCombo);
                return;
            }

            string currentDirectory;
            if (BreadCrumbTrail.Items.Count > 2)
                currentDirectory = (string)BreadCrumbTrail.Items[BreadCrumbTrail.Items.Count - 1].Tag;
            else if (_overflowStack.Any())
                currentDirectory = (string) _overflowStack.Peek().Tag;
            else
                currentDirectory = string.Empty;

            _fileCombo = new ComboBox
                                {
                                    Text = currentDirectory,
                                    Anchor =
                                        AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
                                    Width = BreadCrumbTrail.Width - BreadCrumbTrail.Items[0].Width + HistoryButton.Width-1,
                                    Location = new Point(BreadCrumbTrail.Items[0].Width,0),
                                    FlatStyle = FlatStyle.Flat,
                                    AutoCompleteMode = AutoCompleteMode.SuggestAppend,
                                    AutoCompleteSource = AutoCompleteSource.FileSystemDirectories
                                };
            _fileCombo.Items.Add(currentDirectory);
            var history = FolderHistoryInterface.GetRecentFolders();
            foreach (var item in history.Where(item => !string.IsNullOrEmpty(item) && item != currentDirectory))
                _fileCombo.Items.Add(item);

            _fileCombo.KeyDown += (x, y) =>
                                      {
                                          if (y.KeyCode == Keys.Return)
                                          {
                                              y.Handled = true;
                                              if (Directory.Exists(_fileCombo.Text))
                                              {
                                                  _fileCombo.Visible = false;
                                                  Controls.Remove(_fileCombo);
                                                  Navigate(_fileCombo.Text.TrimEnd('\\'), null);
                                              }
                                              else
                                                  MessageBox.Show("Directory does not exist");
                                          }
                                          else if (y.KeyCode == Keys.Escape)
                                          {
                                              _fileCombo.Visible = false;
                                              Controls.Remove(_fileCombo);
                                              return;
                                          }
                                      };

            Controls.Add(_fileCombo);
            _fileCombo.Select();
            _fileCombo.SelectionStart = _fileCombo.Text.Length;

            if (sender == HistoryButton)
                _fileCombo.DroppedDown = true;
            _fileCombo.BringToFront();
        }
        private void AddMidpoint(SolarSystem systemToAdd)
        {
            //Get a count of all the ComboBox's in the panel
            int controlCount = 0;
            foreach (Control cont in pnlMidpoints.Controls)
                if (cont.GetType() == typeof(ComboBox))
                    controlCount++;

            //Configure the textbox to be similar to the start / end desto properties
            ComboBox newTextBox = new ComboBox();
            pnlMidpoints.Controls.Add(newTextBox);

            newTextBox.ValueMember = "SolarSystemID";
            newTextBox.DisplayMember = "SolarSystemName";
            newTextBox.DropDownStyle = ComboBoxStyle.Simple;
            newTextBox.Tag = controlCount + 1;

            if (systemToAdd.SolarSystemName != null)
            {
                //If the system parsed is a legit system, set the combo box's text and selected item to the parsed system
                newTextBox.Text = systemToAdd.SolarSystemName;
                newTextBox.Items.Add(systemToAdd);
                newTextBox.SelectedItem = systemToAdd;
            }

            //We dont store each individual solar system, so when they select an item from the dropdown, just close it backup.
            newTextBox.SelectedIndexChanged += (object o, EventArgs e) =>
            {
                newTextBox.Size = new Size(newTextBox.Size.Width, 23);
            };

            //When the textbox text is updated, behave EXACTLY like the static start / desto boxes
            newTextBox.TextUpdate += (object o, EventArgs e) =>
            {
                newTextBox.Items.Clear();
                //Get the containers current sizes
                Size contSize = newTextBox.Size;
                string userText = newTextBox.Text;
                //If the user has entered 3 or more chars, lets do a lookup. If its less... Ignore it, we dont want to search this vague
                if (userText.Length >= 3)
                {
                    //Get all systems that are similar to the entered values
                    IEnumerable<SolarSystem> systems = _dataRepository.GetSolarSystemsLikeName(userText);
                    if (systems.Count() > 0)
                    {
                        newTextBox.Items.AddRange(systems.ToArray());
                        //New items were added, so we want to display the drop down so they can select one. They MUST select one.
                        newTextBox.DropDownStyle = ComboBoxStyle.Simple;
                        //Height of the drop down is either 121 if the list height exceedes 121, with a height of 21 for each item. If less, the drop down is equal to minimum height for the items.
                        int height = ((systems.Count() * 21) > 100) ? 121 : ((systems.Count() * 21) + 21);
                        //Re-size the combo back to standard if less than 3 values entered. This is because they might exceed 3, then backspace.
                        newTextBox.Size = new Size(contSize.Width, height);
                        newTextBox.BringToFront();
                    }
                    else
                        //If there are no systems, hide the drop down (Even if its not shown)
                        newTextBox.Size = new Size(contSize.Width, 21);
                }
                else
                {
                    //If there are no systems, hide the drop down (Even if its not shown)
                    newTextBox.Size = new Size(contSize.Width, 21);
                }
                //Highlight the whole combobox, and put the cursor at the end
                newTextBox.Select(newTextBox.Text.Length, 0);
                //Bring the dropdown to the front so nothing obstructs it.
                newTextBox.BringToFront();
            };
            newTextBox.Size = new Size(140, 21);
            //Calcualate the next logical position based on the existing controls. 10 padding
            if (controlCount > 0)
                newTextBox.Location = new Point(10, ((controlCount * 21) + controlCount * 9) + 9);
            else
                newTextBox.Location = new Point(10, 9);
        }
Beispiel #12
0
 /// <include file='doc\ToolStripComboBox.uex' path='docs/doc[@for="ToolStripComboBox.Select"]/*' />
 public void Select(int start, int length)
 {
     ComboBox.Select(start, length);
 }