home links tools blog about
home

« VSTS Extensibility - PcwTESample | Main | A Corrupt Judge? »

December 21, 2005

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d8341ce4d453ef00d8349c454769e2

Listed below are links to weblogs that reference Winforms: Implementing Auto Indenting:

Comments

Chris Frazier

Yeah - you're *handling* the KeyPress event. Instead, *override* it, and just use 'this' in your Handle* methods. i.e.:

protected override void OnKeyPress(KeyPressEventArgs e){
if(e.KeyChar == 13){
e.Handled = this.HandleBlockTabbing();
}else if(e.KeyChar == '>'){
e.Handled = this.HandleTagCompletion();
}

//CF: this call will let forms authors add
//logic if they wish in thier consuming code.
//Handling the event will instead run in
//'parallel' with no guarantee as to which gets
//called first.
base.OnKeyPress(e);
}

Chris Frazier

Forgot - as a test, try putting the same logic into a Form with a regular textbox (and using the KeyPress event handler). I betcha you get the same results as the subclassed textbox.

Michael K. Campbell

Chris,

Thanks for the feedback.

As a matter of fact, i started out in a normal winform and handled the event as you suggested. Then when I was done with all of my different approaches/etc.

Once that was working, around midnight, i decided to create a subclass of textbox to put in all of my code cleanly etc.

By that time i was braindead - and forgot to override - so thanks for the feedback. I would have gone right ahead and used this (thinking that i had subclassed correctly when in fact i had pulled a brain fart).

Chris Frazier

"By that time"? How does it feel to not be braindead 24/7 like me? :)

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.