本文整理汇总了C#中System.Windows.Forms.TextBoxBase.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# TextBoxBase.Invoke方法的具体用法?C# TextBoxBase.Invoke怎么用?C# TextBoxBase.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TextBoxBase
的用法示例。
在下文中一共展示了TextBoxBase.Invoke方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendText
public static void AppendText(TextBoxBase control, string text)
{
if (control.InvokeRequired)
control.Invoke(new AppendTextDelegate(AppendText), control, text);
else
control.AppendText(text);
}
示例2: TextBoxTracer
public TextBoxTracer(TextBoxBase t, StringCollection data)
{
this.txtLog = t;
this.logData = data;
writeAction = s => t.Invoke(new Action(() =>
{
t.Text += s;
}));
}
示例3: AppendText
public static void AppendText(TextBoxBase tb, string text)
{
if (tb == null) return;
tb.SuspendLayout();
if (tb.InvokeRequired)
{
tb.Invoke(new AppendTextDelegate(AppendText), new object[] { tb, text });
}
else
{
tb.SelectionStart = tb.TextLength;
tb.SelectedText = text;
}
tb.ResumeLayout();
}
示例4: SetCaretPosition
/// <summary>
/// Sets the caret position in a text box.
/// This is just a helper function that takes care of
/// cross-thread invokations that would result in .NET
/// exceptions.
/// </summary>
public static void SetCaretPosition(TextBoxBase textBox, int position)
{
if (textBox.InvokeRequired)
{
textBox.Invoke(new setCaretPosition(SetCaretPosition), textBox, position);
}
else
{
textBox.SelectionStart = position;
}
}
示例5: GetSelectedText
/// <summary>
/// Returns selected text in the text box
/// </summary>
/// <param name="control">text box</param>
/// <returns>selected text</returns>
public static String GetSelectedText(TextBoxBase control)
{
if (control.InvokeRequired)
{
return (String)control.Invoke(new getSelectedText(GetSelectedText), control);
}
return control.SelectedText;
}
示例6: GetCaretPosition
/// <summary>
/// Returns the caret position in a text box.
/// This is just a helper function that takes care of
/// cross-thread invokations that would result in .NET
/// exceptions.
/// </summary>
public static int GetCaretPosition(TextBoxBase textBox)
{
if (textBox.InvokeRequired)
{
return (int)textBox.Invoke(new getCaretPosition(GetCaretPosition), textBox);
}
else
{
return textBox.SelectionStart;
}
}
示例7: UnselectText
/// <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);
}
}
}
示例8: RecuperarTexto
/// <summary>
/// Recupera de forma segura o conteúdo do TextBox.
/// </summary>
/// <returns>Conteúdo do TextBox.</returns>
private string RecuperarTexto(TextBoxBase txt)
{
if (txt.InvokeRequired)
{
RecuperarTextoCallback método = new RecuperarTextoCallback(RecuperarTexto);
try
{
return (string)txt.Invoke(método, txt);
}
catch (Exception)
{
return "";
}
}
else
return txt.Text;
}