Trying to manipulate Bold, Italic and Underline Text

  • Thread starter Thread starter Carlo Goretti
  • Start date Start date
C

Carlo Goretti

Guest
Hey!

Im trying to make a program that can feel if a word in richtextbox is bold for example.
If a word is bold for example "Test" then it put <b> around the word.. I cant get it to work.. When im writing test test then it replaces both of them.. Some ideas how i only can change the bold one?
Ask if you dont understand :)

//var output = "";
//for (MallTextRichtxt.SelectionStart = 0; MallTextRichtxt.SelectionStart < MallTextRichtxt.TextLength; MallTextRichtxt.SelectionStart++)
//{
// MallTextRichtxt.SelectionLength = 1;

// var s = MallTextRichtxt.SelectionFont.Style;

// if ((s & FontStyle.Bold) != 0)
// {
// output += MallTextRichtxt.SelectedText;

// }
// else
// {

// }

//}



//string[] lines = output.Split(new[] { " " }, StringSplitOptions.None);
//string Test = MallTextRichtxt.Text;
//string test2 = "";
//if (output.Contains(" "))
//{
// for (int i = 0; i < lines.Count(); i++)
// {
// if (lines != "")
// {
// //Test.Replace(lines.ToString(), "<b>" + lines.ToString() + "</b>");
// test2 = Test.Replace(lines, "<b>" + lines + "</b>");

// }
// else
// {

// }


// }
// MessageBox.Show(test2);
//}
//else
//{


// try
// {
// test2 = Test.Replace(output, "<b>" + output + "</b>");
// MessageBox.Show(test2);
// }
// catch
// {
// MessageBox.Show("Det gick inte att köra replace");
// }


//}


Best regards

Continue reading...
 
Back
Top