Click here to Skip to main content
16,004,727 members
Home / Discussions / C#
   

C#

 
GeneralError in DBconnection Pin
chanzeb3-Feb-08 18:40
chanzeb3-Feb-08 18:40 
GeneralRe: Error in DBconnection Pin
xString3-Feb-08 19:36
xString3-Feb-08 19:36 
GeneralRe: Error in DBconnection Pin
N a v a n e e t h3-Feb-08 19:47
N a v a n e e t h3-Feb-08 19:47 
QuestionDateTime problem??? Pin
Neo Andreson3-Feb-08 18:17
Neo Andreson3-Feb-08 18:17 
AnswerRe: DateTime problem??? Pin
xString3-Feb-08 19:47
xString3-Feb-08 19:47 
General[Message Deleted] Pin
Neo Andreson3-Feb-08 17:33
Neo Andreson3-Feb-08 17:33 
GeneralRe: How to convert string to DateTime??? Pin
Expert Coming3-Feb-08 17:41
Expert Coming3-Feb-08 17:41 
GeneralRichtextbox color change dinamically Pin
gericooper3-Feb-08 17:12
gericooper3-Feb-08 17:12 
hi
task: there's a string array with 1 & 2 char strings. If user strikes the chars matches among one in the array, the prog changes user input for example from "aa"(=user input) to "aA"(in array). It is all done handling the textchanged event of the richtextbox. (last 1 or last 2 chars input)
but: the "one char string" would be nice to be presented by blue color the "2 char string" for example with red. Still cannot figure out why the code below doesn't work but it changes all chars red, it only correct for the first & second recognized thing like so:
"aA"s" but when input again "aA" the whole thing is changed to red (but "s" should be remained blue)
thx for your ideas

the event handling
<br />
private void richTextBox1_TextChanged(object sender, EventArgs e)<br />
        {<br />
            if (richTextBox1.Text.Length >= 2 && !boolfound)<br />
            {<br />
<br />
                Array.Find(mnames, FindM);<br />
<br />
            }<br />
        }<br />


invokes this(1 & 2 chars matching section):

<br />
private  bool FindM(String s)<br />
        {<br />
<br />
            if (s.Equals(richTextBox1.Text.Substring(richTextBox1.Text.Length - 2, 2), StringComparison.CurrentCultureIgnoreCase))<br />
            {<br />
                <br />
                <br />
               richTextBox1.Text= richTextBox1.Text.Remove(richTextBox1.Text.Length - 2,2);<br />
          <br />
               richTextBox1.Focus();<br />
               richTextBox1.Select(richTextBox1.Text.Length, 0);<br />
               richTextBox1.AppendText(s);<br />
<br />
               richTextBox1.SelectionStart = richTextBox1.Text.Length - 2;<br />
               richTextBox1.SelectionLength = 2;<br />
                <br />
                richTextBox1.SelectionColor = Color.Red;<br />
                richTextBox1.DeselectAll();<br />
              richTextBox1.Select(richTextBox1.Text.Length, 0);<br />
               <br />
                   <br />
                    boolfound = false;<br />
                    return true;<br />
                <br />
            }<br />
                if(s.Equals(richTextBox1.Text.Substring(richTextBox1.Text.Length - 1, 1),  StringComparison.CurrentCultureIgnoreCase))<br />
                {<br />
                    <br />
                richTextBox1.Text=richTextBox1.Text.Remove(richTextBox1.Text.Length - 1,1);<br />
<br />
                richTextBox1.Focus();<br />
<br />
<br />
                richTextBox1.Select(richTextBox1.Text.Length, 0);<br />
                    richTextBox1.AppendText(s);<br />
                    richTextBox1.SelectionStart = richTextBox1.Text.Length - 1;<br />
                    richTextBox1.SelectionLength = 1;<br />
                    richTextBox1.SelectionColor = Color.Blue;<br />
                    richTextBox1.DeselectAll();<br />
                   richTextBox1.Select(richTextBox1.Text.Length, 0);<br />
                    <br />
                    boolfound = false;<br />
                    <br />
                    return true;<br />
                }<br />
           <br />
            else<br />
            {<br />
                return false;<br />
            }<br />
            <br />
<br />
        }<br />
<br />

GeneralRe: Richtextbox color change dinamically Pin
gericooper4-Feb-08 6:07
gericooper4-Feb-08 6:07 
GeneralRe: Richtextbox color change dinamically Pin
gericooper4-Feb-08 7:03
gericooper4-Feb-08 7:03 
GeneralA better way for DBNull Pin
Jacob Dixon3-Feb-08 15:45
Jacob Dixon3-Feb-08 15:45 
GeneralRe: A better way for DBNull Pin
Guffa3-Feb-08 16:46
Guffa3-Feb-08 16:46 
GeneralRe: A better way for DBNull Pin
PIEBALDconsult3-Feb-08 16:52
mvePIEBALDconsult3-Feb-08 16:52 
GeneralRe: A better way for DBNull Pin
Jacob Dixon3-Feb-08 17:13
Jacob Dixon3-Feb-08 17:13 
GeneralRe: A better way for DBNull Pin
Jacob Dixon3-Feb-08 16:54
Jacob Dixon3-Feb-08 16:54 
GeneralRe: A better way for DBNull Pin
Jacob Dixon3-Feb-08 16:57
Jacob Dixon3-Feb-08 16:57 
GeneralRe: A better way for DBNull Pin
Vikram A Punathambekar3-Feb-08 17:02
Vikram A Punathambekar3-Feb-08 17:02 
GeneralRe: A better way for DBNull Pin
Jacob Dixon3-Feb-08 17:05
Jacob Dixon3-Feb-08 17:05 
General[Message Deleted] Pin
Jacob Dixon3-Feb-08 17:07
Jacob Dixon3-Feb-08 17:07 
GeneralRe: A better way for DBNull Pin
Expert Coming3-Feb-08 17:39
Expert Coming3-Feb-08 17:39 
GeneralRe: A better way for DBNull Pin
Jacob Dixon3-Feb-08 18:50
Jacob Dixon3-Feb-08 18:50 
GeneralRe: A better way for DBNull Pin
Vikram A Punathambekar4-Feb-08 5:45
Vikram A Punathambekar4-Feb-08 5:45 
GeneralRe: A better way for DBNull Pin
Jacob Dixon4-Feb-08 13:40
Jacob Dixon4-Feb-08 13:40 
QuestionHow do i upload files to my ftp using C# ( Windows Application, NOT ASP) Pin
luisgrimaldo3-Feb-08 15:30
luisgrimaldo3-Feb-08 15:30 
AnswerRe: How do i upload files to my ftp using C# ( Windows Application, NOT ASP) Pin
Vikram A Punathambekar3-Feb-08 15:52
Vikram A Punathambekar3-Feb-08 15:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.