Click here to Skip to main content
15,904,348 members
Home / Discussions / C#
   

C#

 
AnswerRe: How put the PNG-Pictrue into the pictureBox? Pin
Thomas Stockwell26-May-07 15:26
professionalThomas Stockwell26-May-07 15:26 
QuestionPrinting a blank page in Active report Pin
Test27030725-May-07 20:41
Test27030725-May-07 20:41 
AnswerRe: Printing a blank page in Active report Pin
Member 1197347511-Jan-17 20:54
Member 1197347511-Jan-17 20:54 
Questionlimited installation Pin
yazeed_pal25-May-07 20:16
yazeed_pal25-May-07 20:16 
QuestionORA-06413: Connection not open. Pin
Muammar©25-May-07 20:00
Muammar©25-May-07 20:00 
AnswerI found the solution:) Pin
Muammar©25-May-07 20:07
Muammar©25-May-07 20:07 
QuestionADO.Net 2.0 Transaction Pin
Agyeman25-May-07 18:04
Agyeman25-May-07 18:04 
Questiondumbed down auto indent/smart indent Pin
simplicitylabs25-May-07 17:34
simplicitylabs25-May-07 17:34 
I have torn the Web apart looking for a solution. The only thing I have found that makes any sense, doesn't work for me. I want to hit the Enter key, read the previous line (the line the cursor just left) and determine how many spaces and/or tabs are before the first character. Then, place the cursor at the same position on the current/new line by adding the correct number of spaces and/or tabs before it including the tabs and/or spaces that may or may not already be there. I know there are controls/classes for sale out there that offer all the cool stuff for smart indenting and syntax highlighting, but I'm not a wealthy man.

private void richTextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
    if (e.KeyChar == (char)Keys.Enter)
    {
        e.Handled = true;
        int pos = richTextBox1.SelectionStart;
        int lineNumber = richTextBox1.GetLineFromCharIndex(pos);
        String currentLineStr = richTextBox1.Lines[lineNumber];

        int firstChar = 0;
        while (firstChar != currentLineStr.Length)
        {
            if (!Char.IsWhiteSpace(currentLineStr[firstChar])) break;
            firstChar++;
        }
        String indent = currentLineStr.Substring(0, firstChar);
        richTextBox1.SelectedText = indent;
    }
}


Thanks in advanced for any help...

(I may be asking about syntax highlighting after I get this part worked out, if I can't figure it out.)
AnswerRe: dumbed down auto indent/smart indent Pin
Dave Herren25-May-07 18:36
Dave Herren25-May-07 18:36 
GeneralRe: dumbed down auto indent/smart indent [modified] Pin
simplicitylabs25-May-07 19:15
simplicitylabs25-May-07 19:15 
GeneralRe: dumbed down auto indent/smart indent Pin
Dave Herren26-May-07 2:49
Dave Herren26-May-07 2:49 
GeneralRe: dumbed down auto indent/smart indent Pin
simplicitylabs26-May-07 6:18
simplicitylabs26-May-07 6:18 
GeneralRe: dumbed down auto indent/smart indent Pin
Dave Herren26-May-07 10:03
Dave Herren26-May-07 10:03 
GeneralRe: dumbed down auto indent/smart indent Pin
simplicitylabs26-May-07 12:22
simplicitylabs26-May-07 12:22 
GeneralRe: dumbed down auto indent/smart indent Pin
Dave Herren26-May-07 16:55
Dave Herren26-May-07 16:55 
GeneralRe: dumbed down auto indent/smart indent Pin
simplicitylabs26-May-07 19:38
simplicitylabs26-May-07 19:38 
GeneralRe: dumbed down auto indent/smart indent Pin
Dave Herren27-May-07 2:07
Dave Herren27-May-07 2:07 
Questionhow to actualize Bug Report Pin
jason_mf25-May-07 17:14
jason_mf25-May-07 17:14 
AnswerRe: how to actualize Bug Report Pin
MatrixCoder25-May-07 17:41
MatrixCoder25-May-07 17:41 
QuestionHello Pin
dhulipudi25-May-07 17:03
dhulipudi25-May-07 17:03 
AnswerRe: Hello Pin
Muammar©25-May-07 20:10
Muammar©25-May-07 20:10 
GeneralRe: Hello Pin
Guffa25-May-07 23:11
Guffa25-May-07 23:11 
AnswerRe: Hello Pin
Guffa25-May-07 23:09
Guffa25-May-07 23:09 
GeneralRe: Hello Pin
dhulipudi26-May-07 0:34
dhulipudi26-May-07 0:34 
GeneralRe: Hello Pin
Paul Conrad27-May-07 6:33
professionalPaul Conrad27-May-07 6:33 

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.