| | |
HTML Editor. Text Color Change
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2008
Posts: 9
Reputation:
Solved Threads: 0
Hello. I'm doing a html editor.
i want a function to the html editor that change the color on the text when I press a button. Example if I write this code in the html editors textbox:
<table><tr><td bgcolor = "abc123">hello</td></tr><table>
And then I press the button would it change the text color like this:
<table><tr><td bgcolor = "abc123">hello</td></tr></table>
What code should I use for that function?
i want a function to the html editor that change the color on the text when I press a button. Example if I write this code in the html editors textbox:
<table><tr><td bgcolor = "abc123">hello</td></tr><table>
And then I press the button would it change the text color like this:
<table><tr><td bgcolor = "abc123">hello</td></tr></table>
What code should I use for that function?
Yes, I give simple example
C# Syntax (Toggle Plain Text)
private char LastChar = ' '; private void richTextBox1_KeyPress(object sender, KeyPressEventArgs e) { if (LastChar == '<') { //Turn On Red after Pressing < character richTextBox1.SelectionColor = Color.Red; } if (e.KeyChar == '>') { //Turn Off Red Color richTextBox1.SelectionColor = richTextBox1.ForeColor; } LastChar = e.KeyChar; }
KSG
The above code that i posted only works when type the tags
When you want change the color by pressing button. I am not familiar with Regular Expression, still a try.
Try this
When you want change the color by pressing button. I am not familiar with Regular Expression, still a try.
Try this
C# Syntax (Toggle Plain Text)
private void button1_Click(object sender, EventArgs e) { Regex regex = new Regex(@"(<\b[^>]*>)|(</\b[^>]*>)", RegexOptions.IgnoreCase | RegexOptions.Compiled); for (Match match = regex.Match(richTextBox1.Text ); match.Success; match = match.NextMatch()) { richTextBox1.Select ( match.Index +1, match.Value.Length -2); richTextBox1.SelectionColor = Color.Red ; richTextBox1.DeselectAll (); } }
Last edited by selvaganapathy; Jul 20th, 2008 at 8:13 am.
KSG
![]() |
Similar Threads
- Tutorial: Forms: styling text fields with CSS and HTML (Site Layout and Usability)
- Pleeeeeeeese help me (JSP)
- Easy? Image in Form content? (JavaScript / DHTML / AJAX)
- Page Rank on Google? (Search Engine Optimization)
- "cannot resolve symbol"problem (Java)
- Error loading "bridge.dll" (Viruses, Spyware and other Nasties)
- HiJackThis log (Viruses, Spyware and other Nasties)
Other Threads in the C# Forum
- Previous Thread: no caching while copy
- Next Thread: help with text file
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# check checkbox client combobox connection console control conversion csharp custom database datagrid datagridview dataset datetime degrees deployment developer development draganddrop drawing editing encryption enum event excel file form format forms function gdi+ hospitalmanagementinformationsystem httpwebrequest image imageprocessing index input install java label list listbox mandelbrot math mouseclick mysql operator oracle path photoshop picturebox pixelinversion post priviallages. programming radians regex remote remoting richtextbox rows serialization server sleep socket sql statistics stream string table temperature text textbox thread time timer txt update uploadatextfile usercontrol validation visualstudio webbrowser windows windowsformsapplication winforms wpf xml





