Click here to Skip to main content
15,906,626 members
Home / Discussions / C#
   

C#

 
GeneralRe: Creating object instance only known object name Pin
Bilal Farooq21-Apr-04 22:20
Bilal Farooq21-Apr-04 22:20 
GeneralUsing Images of Satellite Assemblies Pin
Bilal Farooq21-Apr-04 19:54
Bilal Farooq21-Apr-04 19:54 
GeneralRe: Using Images of Satellite Assemblies Pin
Heath Stewart22-Apr-04 3:29
protectorHeath Stewart22-Apr-04 3:29 
GeneralGet currently active window Pin
Bilal Farooq21-Apr-04 19:42
Bilal Farooq21-Apr-04 19:42 
GeneralRe: Get currently active window Pin
A.Wegierski22-Apr-04 0:26
A.Wegierski22-Apr-04 0:26 
GeneralRe: Get currently active window Pin
Bilal Farooq22-Apr-04 3:29
Bilal Farooq22-Apr-04 3:29 
GeneralRe: Get currently active window Pin
Heath Stewart22-Apr-04 3:39
protectorHeath Stewart22-Apr-04 3:39 
Generalauto+indentation feature Pin
kumaru_san21-Apr-04 19:04
kumaru_san21-Apr-04 19:04 
Hello

I am developing a syntax editor .

I need to give auto indentation feature to my editor .
I use C#.And i use richtextbox.

In the key press event ..

I try the following ..

private void richTextBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{

// open and close braces indexes
int indexOfOpen;
int indexOfClose;
int lineno;

if (e.KeyValue == 221) // checking for "}" key
{

System.Diagnostics.Trace.WriteLine(this.richTextBox1.GetLineFromCharIndex(this.richTextBox1.SelectionStart).ToString());

// getting line number
lineno = this.richTextBox1.GetLineFromCharIndex(this.richTextBox1.SelectionStart);

while(lineno>0)
{

/*take the previous line from the position of "}" backwards and if it finds "{" charecter .get the
position of "{" charecter and adjust the position of
"}" charecter to the "{" charecter position.
*/


string[] test = this.richTextBox1.Lines;

string previousline = test[lineno-1];

if( previousline.StartsWith("{") )
{
indexOfOpen = previousline.IndexOf("{");

Point pos1 = this.richTextBox1.GetPositionFromCharIndex(indexofopen);

string currentline = test[lineno];

indexOfClose = currentline.IndexOf("}");

Point pos2 = this.richTextBox1.GetPositionFromCharIndex(indexOfClose);

pos2.X = pos1.X;

}

lineno--;
}

}

// check for the enter key
else if(e.KeyValue == 13)
{
string[] contents = richTextBox1.Lines;
int ilen = contents.Length;
string str = contents[ilen-1];
// setting indentation

richTextBox1.SelectionIndent = richTextBox1.SelectionStart;
}

Its somewhere mistake.I am new to C#.

Please can u correct me or give me sample code snippets?

I will be greatly helpful to me.

..

"They can because they think they can" - Voltaire
GeneralRe: auto+indentation feature Pin
leppie22-Apr-04 7:29
leppie22-Apr-04 7:29 
GeneralRe: auto+indentation feature Pin
kumaru_san22-Apr-04 18:32
kumaru_san22-Apr-04 18:32 
QuestionHow to float window over application properly Pin
Michael Wolski21-Apr-04 18:10
Michael Wolski21-Apr-04 18:10 
AnswerRe: How to float window over application properly Pin
Heath Stewart22-Apr-04 3:42
protectorHeath Stewart22-Apr-04 3:42 
GeneralRe: How to float window over application properly Pin
Michael Wolski22-Apr-04 4:20
Michael Wolski22-Apr-04 4:20 
Generalusercontrol Pin
Member 102128921-Apr-04 16:42
Member 102128921-Apr-04 16:42 
QuestionHow can I send an Image over a socket connection? Pin
Gakujin21-Apr-04 16:20
Gakujin21-Apr-04 16:20 
AnswerRe: How can I send an Image over a socket connection? Pin
Michael Wolski21-Apr-04 18:40
Michael Wolski21-Apr-04 18:40 
GeneralRe: How can I send an Image over a socket connection? Pin
Tim Kohler22-Apr-04 1:32
Tim Kohler22-Apr-04 1:32 
GeneralList box line spacing Pin
interlocked21-Apr-04 15:26
interlocked21-Apr-04 15:26 
GeneralAuto complete in custom web browser Pin
Weiye Chen21-Apr-04 15:22
Weiye Chen21-Apr-04 15:22 
GeneralRe: Auto complete in custom web browser Pin
Roman Rodov21-Apr-04 17:36
Roman Rodov21-Apr-04 17:36 
GeneralSetup & Deployment project - "All User" installation Pin
Ruchi Gupta21-Apr-04 13:47
Ruchi Gupta21-Apr-04 13:47 
GeneralRe: Setup & Deployment project - "All User" installation Pin
sreejith ss nair21-Apr-04 18:59
sreejith ss nair21-Apr-04 18:59 
GeneralRe: Setup & Deployment project - "All User" installation Pin
Ruchi Gupta22-Apr-04 5:00
Ruchi Gupta22-Apr-04 5:00 
GeneralRe: Setup & Deployment project - "All User" installation Pin
Heath Stewart22-Apr-04 3:52
protectorHeath Stewart22-Apr-04 3:52 
GeneralRe: Setup & Deployment project - "All User" installation Pin
Ruchi Gupta22-Apr-04 4:52
Ruchi Gupta22-Apr-04 4: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.