Select() public méthode

public Select ( int start, int length ) : void
start int
length int
Résultat void
Exemple #1
0
 public static void SetRichTextBoxDropString(System.Windows.Forms.TextBoxBase yourCtr, Action action = null)
 {
     if (yourCtr == null)
     {
         return;
     }
     if (yourCtr is RichTextBox)
     {
         ((RichTextBox)yourCtr).AllowDrop = true;
     }
     else if (yourCtr is TextBox)
     {
         ((TextBox)yourCtr).AllowDrop = true;
     }
     else
     {
         yourCtr.AllowDrop = true;
     }
     yourCtr.DragDrop += (sender, e) =>
     {
         System.Windows.Forms.TextBoxBase tempTextBoxBase = sender as System.Windows.Forms.TextBoxBase;
         string tempText = (string)e.Data.GetData(typeof(string));
         if (tempText == null || tempTextBoxBase == null)
         {
             return;
         }
         int selectionStart = tempTextBoxBase.SelectionStart;
         tempTextBoxBase.Text = tempTextBoxBase.Text.Insert(selectionStart, tempText);
         tempTextBoxBase.Select(selectionStart, tempText.Length);
         action?.Invoke();
     };
     yourCtr.DragEnter += (sender, e) =>
     {
         if (e.Data.GetData(typeof(string)) == null)
         {
             e.Effect = System.Windows.Forms.DragDropEffects.None;
         }
         else
         {
             e.Effect = System.Windows.Forms.DragDropEffects.Move;
         }
     };
 }
Exemple #2
0
        internal static void Find(TextBoxBase textBox, string findString, bool caseSensitive, bool upwards)
        {
            var comparison = caseSensitive
                           ? StringComparison.CurrentCulture
                           : StringComparison.CurrentCultureIgnoreCase;

            var text = textBox.Text;
            if (text.IndexOf(findString, comparison) == -1)
            {
                ShowFormattedMessageBox("Cannot find \"{0}\".", findString);
                return;
            }

            var foundIndex = Find(text, textBox.SelectionStart, textBox.SelectionLength, findString, comparison, upwards);
            if (foundIndex == -1)
            {
                ShowFormattedMessageBox("No further occurences of \"{0}\" have been found.", findString);
                return;
            }

            textBox.Select(foundIndex, findString.Length);
            textBox.ScrollToCaret();
        }
Exemple #3
0
 public static void scrollToEnd(TextBoxBase txb)
 {
     txb.Focus();
     txb.Select(txb.TextLength, 0);
 }
Exemple #4
0
 /// <summary>
 /// Unselect text in textbox
 /// </summary>
 /// <param name="control">the text box control</param>
 public static void UnselectText(TextBoxBase control)
 {
     if (control.InvokeRequired)
     {
         control.Invoke(new unselectText(UnselectText), control);
     }
     else
     {
         control.SelectionLength = 0;
         if (!String.IsNullOrEmpty(control.Text))
         {
             control.Select(control.Text.Length, 0);
         }
     }
 }
Exemple #5
0
 /// <summary>
 /// Moves the input caret to the end of the TextBox's current text (no text is actually selected).
 /// </summary>
 public static void SelectEnd(this System.Windows.Forms.TextBoxBase textBox)
 {
     textBox.Select(textBox.Text?.Length ?? 0, 0);
 }