本文整理汇总了C#中System.Windows.Forms.RichTextBox.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.Clear方法的具体用法?C# RichTextBox.Clear怎么用?C# RichTextBox.Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.RichTextBox
的用法示例。
在下文中一共展示了RichTextBox.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetRTF
public static void SetRTF(RichTextBox rtb, string rtf, string colorTable)
{
rtb.Clear();
rtb.Text = "rtfing...";
var orgRtf = rtb.Rtf;
rtb.Clear();
orgRtf = InsertColorTable(orgRtf, colorTable);
orgRtf = orgRtf.Replace("rtfing...", rtf);
rtb.Rtf = orgRtf;
}
示例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: FillCodeTextBox
//Очистка и заполнение текстбокса из фалйа
public static void FillCodeTextBox(string filename, ref RichTextBox CodeRTextBox)
{
StreamReader FileIn;
try
{
FileIn = new StreamReader(filename);
}
catch (IOException exc)
{
MessageBox.Show("Ошибка открытия файла!\n" + exc.Message);
return;
}
CodeRTextBox.Clear();
try
{
while (!FileIn.EndOfStream)
{
CodeRTextBox.Text += FileIn.ReadLine();
if (!FileIn.EndOfStream)
CodeRTextBox.Text += '\n';
}
}
catch (IOException exc)
{
MessageBox.Show("Ошибка чтения файла:\n" + exc.Message);
}
finally
{
FileIn.Close();
CurrentFileName = filename;
}
}
示例4: 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();
}
示例5: RetrieveWeb
/// <summary>
/// note: not threadsafe
/// </summary>
public static SPWeb RetrieveWeb(string siteUrl, RichTextBox rtbValidateMessage)
{
try
{
MainForm.DefInstance.Cursor = Cursors.WaitCursor;
rtbValidateMessage.Clear();
if (siteUrl.Trim() == "")
{
SmartStepUtil.AddToRTB(rtbValidateMessage, "site URL is blank", Color.Red, 8, false, SmartStepUtil.enumIcon.red_x);
return null;
}
SPSite site;
try
{
site = new SPSite(siteUrl);
}
catch (Exception ex)
{
SmartStepUtil.AddToRTB(rtbValidateMessage, "site not found: " + ex.Message + " ", Color.Red, 8, false, SmartStepUtil.enumIcon.red_x);
return null;
}
SPWeb web = site.OpenWeb();
SmartStepUtil.AddToRTB(rtbValidateMessage, "site found: " + web.Url + " ", Color.Green, 8, false, SmartStepUtil.enumIcon.green_check);
return web;
}
finally
{MainForm.DefInstance.Cursor = Cursors.Default;}
}
示例6: Transport
// Конструктор
public Transport(ref RichTextBox rTB, double[,] стоимости, double[] потребители, double[] поставщики)
{
окно = rTB;
// Очистим окно
окно.Clear();
// Инициализируем переменный
Стоимости = стоимости;
Потребители = потребители;
Поставщики = поставщики;
КонечнаяСумма = 0;
КоличествоПоставщиков = Поставщики.Length;
КоличествоПотребителей = Потребители.Length;
NVeryLargeNumber = 99999999999;
nomer = 0;
// Т.к. это эпсилон метод - добавим небольшие величины к поставщикам и потребителям
var эпсилон = 0.001;
for (int i = 0; i < КоличествоПотребителей; i++)
{
Потребители[i] += (double)эпсилон / Потребители.Length;
}
окно.Text += '\n' + "Эпсилон: " + эпсилон;
Поставщики[1] += (double)эпсилон;
МатрицаПоискаОптимальногоПлана = new double[КоличествоПоставщиков, КоличествоПотребителей];
for (int i = 0; i < КоличествоПоставщиков; i++)
{
for (int j = 0; j < КоличествоПотребителей; j++)
{
МатрицаПоискаОптимальногоПлана[i, j] = 0;
}
}
ДвойственнаяМатрица = new double[КоличествоПоставщиков, КоличествоПотребителей];
for (int i = 0; i < КоличествоПоставщиков; i++)
{
for (int j = 0; j < КоличествоПотребителей; j++)
{
ДвойственнаяМатрица[i, j] = -1;
}
}
// Начинаем решение с запуска метода сев-западного угла
МетодСевероЗападногоУгла();
X_КоординатаОпорнойТочки = -1;
Y_КоординатаОпорнойТочки = -1;
ПечатьШага();
}
示例7: TextBoxAppender
public TextBoxAppender(RichTextBox textbox) {
this._textBox = textbox;
WriteLog = (msg, level) => {
try {
if (_screentextLength > 0xFFFF) {
_textBox.Clear();
_screentextLength = 0;
}
_textBox.SelectionColor = _logColors[level.Value / 10000 - 4];
_textBox.AppendText(msg);
_screentextLength += msg.Length;
} catch { }
};
}
示例8: RichTextBoxAppender
public RichTextBoxAppender(RichTextBox rtb)
{
if (rtb == null)
{
throw new ArgumentNullException("rtb");
}
rtb.ReadOnly = true;
rtb.HideSelection = false;
rtb.Clear();
RichTextBox = rtb;
var patterLayout = new PatternLayout {ConversionPattern = "%d{dd MMM HH:mm:ss} %-5p - %m%n"};
patterLayout.ActivateOptions();
Layout = patterLayout;
}
示例9: readFile
public void readFile(string path, RichTextBox richTextBox)
{
richTextBox.Clear();
richTextBox.SelectionAlignment = HorizontalAlignment.Left;
richTextBox.SelectionIndent = 20;
richTextBox.SelectionHangingIndent = -20;
StreamReader din = File.OpenText(path);
String str;
ArrayList al = new ArrayList();
while ((str = din.ReadLine()) != null)
{
al.Add(str);
}
foreach (string s in al)
{
richTextBox.SelectedText += s;
richTextBox.SelectedText += "\r\n";
}
}
示例10: ResetDescription
public void ResetDescription(RichTextBox rtbDescription)
{
rtbDescription.Clear();
var doubleNewLine = Environment.NewLine + Environment.NewLine;
Font original = rtbDescription.SelectionFont;
Font fntBold = new Font(original.FontFamily, original.Size, FontStyle.Bold);
Font fntItalic = new Font(original.FontFamily, original.Size, FontStyle.Italic);
rtbDescription.SelectionFont = fntBold;
rtbDescription.AppendText(m_term);
rtbDescription.AppendText(doubleNewLine);
rtbDescription.SelectionFont = (m_def == null || m_def == String.Empty) ? fntItalic : original;
rtbDescription.AppendText((m_def == null || m_def == String.Empty) ? LexTextControls.ksUndefinedItem : m_def);
rtbDescription.AppendText(doubleNewLine);
if (m_citations.Count > 0)
{
rtbDescription.SelectionFont = fntItalic;
rtbDescription.AppendText(LexTextControls.ksReferences);
rtbDescription.AppendText(doubleNewLine);
rtbDescription.SelectionFont = original;
foreach (MasterCategoryCitation mcc in m_citations)
mcc.ResetDescription(rtbDescription);
}
#if __MonoCS__
// Ensure that the top of the description is showing (FWNX-521).
rtbDescription.Select(0,0);
rtbDescription.ScrollToCaret();
#endif
}
示例11: ResetDescription
public void ResetDescription(RichTextBox rtbDescription)
{
CheckDisposed();
rtbDescription.Clear();
Font original = rtbDescription.SelectionFont;
Font fntBold = new Font(original.FontFamily, original.Size, FontStyle.Bold);
Font fntItalic = new Font(original.FontFamily, original.Size, FontStyle.Italic);
rtbDescription.SelectionFont = fntBold;
rtbDescription.AppendText(m_term);
rtbDescription.AppendText("\n\n");
rtbDescription.SelectionFont = (string.IsNullOrEmpty(m_def)) ?
fntItalic : original;
rtbDescription.AppendText((string.IsNullOrEmpty(m_def)) ?
MGAStrings.ksNoDefinitionForItem : m_def);
rtbDescription.AppendText("\n\n");
if (m_citations.Count > 0)
{
rtbDescription.SelectionFont = fntItalic;
rtbDescription.AppendText(MGAStrings.ksReferences);
rtbDescription.AppendText("\n\n");
rtbDescription.SelectionFont = original;
foreach (MasterItemCitation mifc in m_citations)
mifc.ResetDescription(rtbDescription);
}
}
示例12: show_sub_item
private void show_sub_item(log_view lv, info_type type, RichTextBox text_ctrl) {
match_item item = lv.sel;
int row = lv.sel_row_idx;
string txt = (item as filter.match).line.part(type);
int col = log_view_cell.info_type_to_cell_idx(type);
var prints = lv.sel.override_print(lv, txt, type);
print_info.to_single_enter_char(ref txt, ref prints);
text_ctrl.Clear();
text_ctrl.AppendText(txt);
var full_row = lv.list.GetItem(row);
text_ctrl.BackColor = drawer_.bg_color(full_row, col);
int last_idx = 0;
for (int print_idx = 0; print_idx < prints.Count; ++print_idx) {
int cur_idx = prints[print_idx].Item1, cur_len = prints[print_idx].Item2;
string before = txt.Substring(last_idx, cur_idx - last_idx);
if (before != "") {
text_ctrl.Select(last_idx, cur_idx - last_idx);
text_ctrl.SelectionColor = drawer_.print_fg_color(full_row, default_print_);
text_ctrl.SelectionBackColor = drawer_.bg_color(full_row, col);
}
text_ctrl.Select(cur_idx, cur_len);
text_ctrl.SelectionColor = drawer_.print_fg_color(full_row, prints[print_idx].Item3);
text_ctrl.SelectionBackColor = drawer_.print_bg_color(full_row, prints[print_idx].Item3);
last_idx = cur_idx + cur_len;
}
last_idx = prints.Count > 0 ? prints.Last().Item1 + prints.Last().Item2 : 0;
if (last_idx < txt.Length) {
text_ctrl.Select(last_idx, txt.Length - last_idx);
text_ctrl.SelectionColor = drawer_.print_fg_color(full_row, default_print_);
text_ctrl.SelectionBackColor = drawer_.bg_color(full_row, col);
}
}
示例13: ClearBox
public static void ClearBox(RichTextBox box)
{
box.Clear();
}
示例14: DisplayLoop
public void DisplayLoop(RichTextBox richTextBoxLoop, RichTextBox richTextBoxLoopDelay, int currentIndex = -1)
{
/** Display loop sequence on the GUI. Highlight the indexed command. */
richTextBoxLoop.Clear();
richTextBoxLoopDelay.Clear();
/* Command #index is highlighted. */
if (this.loop.Count > 0)
{
for (int i = 0; i < this.loop.Count; i++)
{
if (i == currentIndex)
{
richTextBoxLoop.SelectionBackColor = Color.Yellow;
richTextBoxLoopDelay.SelectionBackColor = Color.Yellow;
richTextBoxLoop.SelectionStart = richTextBoxLoop.Text.Length;
richTextBoxLoop.ScrollToCaret();
richTextBoxLoopDelay.SelectionStart = richTextBoxLoopDelay.Text.Length;
richTextBoxLoopDelay.ScrollToCaret();
}
else
{
richTextBoxLoop.SelectionBackColor = Color.White;
richTextBoxLoopDelay.SelectionBackColor = Color.White;
}
richTextBoxLoop.AppendText(this.loop[i].Scpi + "\r\n");
richTextBoxLoopDelay.AppendText(this.loop[i].Delay + "\r\n");
}
}
}
示例15: displayAllFrames
internal void displayAllFrames(RichTextBox frameBox)
{
frameBox.Clear();
frameBox.SelectionStart = 0;
int posLine = 0;
foreach (LyricLine line in this.lyricList)
{
line.displayAllFrames(posLine, frameBox);
posLine++;
}
frameBox.SelectionStart = 0;
}