本文整理汇总了C#中System.Windows.Forms.RichTextBox.Focus方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.Focus方法的具体用法?C# RichTextBox.Focus怎么用?C# RichTextBox.Focus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.RichTextBox
的用法示例。
在下文中一共展示了RichTextBox.Focus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: wyswietl
public void wyswietl(RichTextBox o, string tekst)
{
o.Focus();
o.AppendText(tekst);
o.ScrollToCaret();
txtWysylane.Focus();
}
示例2: AppendMsg
/// <summary>
/// 在富文本上打印消息
/// </summary>
/// <param name="richTextBox1">所在打印的富文本</param>
/// <param name="color">打印字体颜色</param>
/// <param name="text">要打印的文本</param>
/// <param name="AutoTime">是否在每条打印结果前追加时间</param>
public void AppendMsg(RichTextBox richTextBox1, Color color, string text,bool AutoTime)
{
richTextBox1.BeginInvoke(new ThreadStart(() =>
{
lock (richTextBox1)
{
//为控件输入焦点
richTextBox1.Focus();
//检查文本框过长
if (richTextBox1.TextLength > 100000 )
{
richTextBox1.Clear();
}
//得到有格式的文本
using (var temp = new RichTextBox())
{
temp.SelectionColor = color;
if (AutoTime)
temp.AppendText(DateTime.Now.ToString("yyyyMMdd HH:mm:ss"));
temp.AppendText(text);
//追加文本
richTextBox1.Select(richTextBox1.Rtf.Length, 0);
richTextBox1.SelectedRtf = temp.Rtf;
}
//设定光标所在位置
//richTextBox1.SelectionStart = richTextBox1.TextLength;
//滚动到当前光标处
//richTextBox1.ScrollToCaret();
}
}));
}
示例3: StartServer
public static void StartServer(ProcessCaller _MangosProcess, ProcessCaller _RealmProcess, string _worldExe, string _realmExe, RichTextBox _Normal, RichTextBox _Error)
{
_Error.Clear();
_Normal.Clear();
_Normal.Focus();
ErrorRich = _Error;
NormalRich = _Normal;
//World
_MangosProcess.FileName = Settings.Default.ServerPath + "\\" + _worldExe;
_MangosProcess.WorkingDirectory = Settings.Default.ServerPath + "\\";
_MangosProcess.StdErrReceived += new DataReceivedHandler(writeStreamInfoError);
_MangosProcess.StdOutReceived += new DataReceivedHandler(writeStreamInfoNormal);
if (IsRunning(_worldExe))
KillProcess(_worldExe);
_MangosProcess.Start();
//Realm
_RealmProcess.FileName = Settings.Default.ServerPath + "\\" + _realmExe;
_RealmProcess.WorkingDirectory = Settings.Default.ServerPath + "\\";
_RealmProcess.StdErrReceived += new DataReceivedHandler(writeStreamInfoError);
_RealmProcess.StdOutReceived += new DataReceivedHandler(writeStreamInfoNormal);
if (IsRunning(_realmExe))
KillProcess(_realmExe);
_RealmProcess.Start();
}
示例4: FindTheText
private static int FindTheText(RichTextBox textBox, string text, int start)
{
// Initialize the return value to false by default.
int returnValue = -1;
// Ensure that a search string has been specified and a valid start point.
if (text.Length > 0 && start >= 0)
{
if (!textBox.Focused)
{
textBox.Focus();
}
// Obtain the location of the search string in richTextBox1.
int indexToText = textBox.Find(text, start, RichTextBoxFinds.None);
// Determine whether the text was found in richTextBox1.
if (indexToText >= 0)
{
returnValue = indexToText;
}
}
if (returnValue == -1)
{
if (start == 0)
{
MessageBox.Show("Text \"" + text + "\" was not found.", "Find text", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (MessageBox.Show("No more occurence of \"" + text + "\" was found.\nSearch from the beginning?", "Find text", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
{
FindTheText(textBox, text, 0);
}
}
return returnValue;
}
示例5: HC
public HC(string apellido, string nombre, string tipodoc, string documento, string telefono, string sexo, string email)
{
this.apellido = apellido;
this.nombre = nombre;
this.tipodoc = tipodoc;
this.documento = documento;
this.telefono = telefono;
this.sexo = sexo;
this.email = email;
lblPacienteHC = new Label();
txtHHCC = new RichTextBox();
btnGuardarHC = new Button();
btnSalirHC = new Button();
this.Width = 500;
this.Height = 500;
this.Text = "Historia Clínica " + apellido + ", " + nombre;
lblPacienteHC.Text = "Historia Clínica " + apellido + ", " + nombre;
lblPacienteHC.Location = new Point(10,10);
txtHHCC.Multiline = true;
txtHHCC.Location = new Point(10,25);
txtHHCC.Width = 450;
txtHHCC.Height = 395;
txtHHCC.Font = new Font("Tahoma", 10, FontStyle.Bold);
btnGuardarHC.Text = "Guardar";
btnGuardarHC.Location = new Point(10,426);
btnSalirHC.Text = "Salir";
btnSalirHC.Location = new Point(100,426);
btnSalirHC.Click += new System.EventHandler(BtnSalirHC_Click);
btnGuardarHC.Click += new System.EventHandler(BtnGuardarHC_Click);
this.Controls.Add(txtHHCC);
this.Controls.Add(btnGuardarHC);
this.Controls.Add(btnSalirHC);
this.Controls.Add(lblPacienteHC);
if (File.Exists(Configuracion.getDirectorioHC() + "\\" + documento + "_HC.dat"))
{
txtHHCC.Lines = File.ReadAllLines(Configuracion.getDirectorioHC() + "\\" + documento + "_HC.dat");
}
txtHHCC.Focus();
txtHHCC.SelectionStart = txtHHCC.Text.Length + 2;
this.ShowDialog();
}
示例6: Highlight
public static void Highlight(RichTextBox myRtb,string Line,Color color)
{
myRtb.SelectionBackColor = Color.White;
myRtb.Focus();
startIndex = myRtb.Find(Line, startIndex, RichTextBoxFinds.None);//Returns the start index of specific Line
if (startIndex > -1)
{
myRtb.Select(startIndex, Line.Length);//Select a line using it's Length and its StartIndex
startIndex += Line.Length;
}
else if (startIndex < 0) // Fixes the Argument Exception
{
startIndex = 0;
Highlight(myRtb, Line,color);//Call it again to highlight the Line
}
}
示例7: wyswietl
private void wyswietl(RichTextBox o, string tekst)
{
this.Invoke(new Action(() =>
{
o.Focus();
o.AppendText(tekst);
o.ScrollToCaret();
}));
}
示例8: ASAutoCopy
/// <summary>
/// Auto copy after convert
/// </summary>
/// <param name="target">The target label to show minder</param>
/// <param name="boss">The target richtextbox contains the string converted</param>
private void ASAutoCopy(Label target, RichTextBox boss, bool tryselectall)
{
if (autoCopy)
{
if (boss.Text.Length > 0)
{
try
{
Clipboard.SetText(boss.Text);
}catch{}
}
Timer timer = new Timer();
timer.Tick += new EventHandler(copiedMessageTimer_Tick);
int COPIEDLABELDURATION = 500;
timer.Interval = COPIEDLABELDURATION;
target.Visible = true;
if (tryselectall || !realtimeConvert || base64FileModeCheckBox.Checked || encodingchoiceBox1.SelectedIndex == 5)
{
boss.Focus();
boss.SelectAll();
}
timer.Tag = target;
timer.Enabled = true;
}
}
示例9: OpenFile
/// <summary>
/// Mở file lấy dữ liệu
/// </summary>
/// <param name="rtx">Một RichTextBox</param>
/// <param name="filter">Chuỗi lọc đuôi mở rộng file</param>
/// <param name="title">Tiêu đề của hộp thoại</param>
private void OpenFile(RichTextBox rtx, String filter, String title)
{
OpenFileDialog f = new OpenFileDialog();
f.Multiselect = false;
f.Filter = filter;
f.Title = title;
if (f.ShowDialog() == DialogResult.OK)
{
FileStream fsr = new FileStream(f.FileName, FileMode.Open, FileAccess.Read);
StreamReader str = new StreamReader(fsr, Encoding.ASCII);
rtx.Text = str.ReadToEnd();
rtx.Focus();
str.Dispose();
fsr.Dispose();
}
}
示例10: SetText
private void SetText(string text, RichTextBox tb)
{
if (tb.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text, tb });
}
else
{
//tb.Text = "";
tb.Text = text;
tb.Select(txtResult.TextLength, 0);
tb.Focus();
}
}
示例11: changeTextColour
/// <summary>
/// Change the colour of the selected text in the text box passed as parameter.
/// </summary>
/// <param name="textBox">The text box contain the text to be recoloured.</param>
/// <param name="newColour">The colour that the selected text shall be.</param>
private void changeTextColour(RichTextBox textBox, Color newColour)
{
if (textBox != null)
{
//check that text acutally has been selected
if (textBox.SelectionLength > 0)
{
//save the selection start and length for later recall
int initSelectStart = textBox.SelectionStart;
int initSelectLength = textBox.SelectionLength;
//change the selected colour to the one passed as parameter
textBox.SelectionColor = newColour;
//go the the end of the selection and make it so any future characters typed have default colour
textBox.SelectionStart = textBox.SelectionStart + textBox.SelectionLength;
textBox.SelectionLength = 0;
textBox.SelectionColor = textBox.ForeColor;
//recall initial selection
textBox.Select(initSelectStart, initSelectLength);
}
else
{
//apply new colour
textBox.SelectionColor = newColour;
}
//change focus from the colour button to the text box
textBox.Focus();
}
}
示例12: Scroll2Last
private void Scroll2Last(RichTextBox rtb)
{
rtb.SelectionStart = rtb.TextLength;
rtb.Focus();
rtb.ScrollToCaret();
}
示例13: ScrollToBottom
public static void ScrollToBottom(RichTextBox rtb)
{
if (MainForm.DefInstance.InvokeRequired)
{
MainForm.DefInstance.BeginInvoke(new delB(ScrollToBottom), new object[] { rtb });
return;
}
rtb.Focus();
rtb.Select(rtb.Text.Length , 0);
rtb.ScrollToCaret();
}
示例14: _lockUVarEditor
private void _lockUVarEditor(RichTextBox editor, bool disabled)
{
if(disabled) {
editor.ReadOnly = true;
editor.BackColor = System.Drawing.SystemColors.Control;
return;
}
editor.BackColor = System.Drawing.SystemColors.Window;
editor.Focus();
editor.ReadOnly = false;
}
示例15: BackSpace
/// <summary>
/// 退格
/// </summary>
public static void BackSpace(RichTextBox txtExp)
{
if (txtExp.SelectionLength > 0)//选择了字符串
{
}
else//没有选择字符串
{
//要删除的是运算符,处理过后选择该运算符
CalOpeList opeList = new CalOpeList();
for (int i = 0; i < opeList.count; i++)
{
if (txtExp.SelectionStart >= opeList.opeList[i].tag.Length
&& opeList.opeList[i].tag == txtExp.Text.Substring(txtExp.SelectionStart - opeList.opeList[i].tag.Length, opeList.opeList[i].tag.Length))
{
txtExp.SelectionStart = txtExp.SelectionStart - opeList.opeList[i].tag.Length;
txtExp.SelectionLength = opeList.opeList[i].tag.Length;
break;
}
}
}
int _cursorPos = txtExp.SelectionStart;
if (txtExp.SelectionLength > 0)//选择了字符串
{
txtExp.Text = txtExp.Text.Remove(_cursorPos, txtExp.SelectionLength);
txtExp.Focus();
txtExp.SelectionStart = _cursorPos;
}
else//没有选择字符串
{
if (_cursorPos - 1 >= 0)
{
txtExp.Text = txtExp.Text.Remove(_cursorPos - 1, 1);
txtExp.Focus();
txtExp.SelectionStart = _cursorPos - 1;
}
else
{
txtExp.Focus();
}
}
}