Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

Catching TAB in Windows Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marcin Waligora - 23 Oct 2004 13:34 GMT
Hi all,

I am trying tu use TAB button in my Windows Form in different way it is
usually intented (usually it jumps between controls). I want to catch while
it is in RichTextBox. I've checked OnKeyPressed, OnKeyDown, however they
never even receive the signal. Does anyone have any idea how to solve this
problem??

Any help is appreciated...
Morten Wennevik - 23 Oct 2004 14:01 GMT
Hi Marcin,

Set the AcceptsTab property in the control to true.

Signature

Happy Coding!
Morten Wennevik [C# MVP]

Marcin Waligora - 23 Oct 2004 14:11 GMT
Is there any other way??
I don't want the RichTextBox to be Multiline.
Morten Wennevik - 23 Oct 2004 18:40 GMT
> Is there any other way??
> I don't want the RichTextBox to be Multiline.

Well, you could catch the enter keypress and ignore it, effectively making  
it singleline although you could possibly paste a multiline string.

Signature

Happy Coding!
Morten Wennevik [C# MVP]

Marcin Waligora - 23 Oct 2004 19:50 GMT
That's generally a problem. I can go with multiline, but I must catch enter
and tab, to prevent them from going into RichTextBox message. This is the
code I use to ignore the ENTER and TAB, but it doesn't work. Tab still moves
caret and enter moves it one line. Is there something wrong in this code??

I really appreciate your help.

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

if(e.KeyCode == Keys.Enter ){

e.Handled = true;}

if(e.KeyCode == Keys.Tab){

e.Handled=true;

}
Morten Wennevik - 24 Oct 2004 11:19 GMT
I'm not sure why the enter gives you a new line as on my system it does  
not.
However, I couldn't prevent TAB doing its default behaviour of adding \t.

You probably need to handle ProcessCmdKey in an inherited RichTextBox.

Signature

Happy Coding!
Morten Wennevik [C# MVP]

Guest - 12 Apr 2005 17:27 GMT
Set the AcceptsTab property on the RichTextBox to True.

> Hi all,
>
[quoted text clipped - 5 lines]
>
> Any help is appreciated...

User submitted from AEWNET (http://www.aewnet.com/)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.