private void RichTextBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control) { // Code for Copy Action if (!string.IsNullOrEmpty(RichTextBox1.Text)) { RichTextBox1.Font = new Font("times new roman", 14f, FontStyle.Regular); RichTextBox1.ForeColor = Color.Black; string firstLine = RichTextBox1.Lines[0]; RichTextBox1.Select(RichTextBox1.GetFirstCharIndexFromLine(0), firstLine.Length); RichTextBox1.SelectionFont = new Font("times new roman", 20f, FontStyle.Bold); } } }
private void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { try { string SelItem = null; int linN = 0; int colN = 0; SelItem = lstErrors.SelectedItem.ToString(); if (!string.IsNullOrEmpty(SelItem)) { linN = Convert.ToInt16(Regex.Replace(SelItem, "([0-9]+): ([0-9]+)(.*)", "$1")); colN = Convert.ToInt16(Regex.Replace(SelItem, "([0-9]+): ([0-9]+)(.*)", "$2")); MatchCollection mc = default(MatchCollection); int i = 0; int totc = 0; mc = Regex.Matches(RichTextBox1.Text, "\\n", RegexOptions.Singleline); try { RichTextBox1.Select(mc[linN - 2].Index + colN, 2); RichTextBox1.SelectionColor = Color.Blue; RichTextBox1.Focus(); } catch (Exception ex) { RichTextBox1.Focus(); } } } catch (Exception ex) { PepsiLiteErrorHandling.WriteErrorLog(ex.ToString()); } }