Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > Run time Create controls
 

Run time Create controls

Hi,
i am createing rich text boxes at runtime,so i want to apply undo,copy paste like mes word,so how can i apply for each rich text box
Venkat ------------------------------------------------ -------------------------------------------------------------------------------- Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Sincerely, Venkat
Venkat Chilkuri  Monday, August 24, 2009 2:21 PM
you should assing a OnKeyPress handler to each richTextBox at creation time. It should be something like that:

        private void action_handler(object sender, System.Windows.Forms.KeyEventArgs e)
        {            
            if (e.Control) {
                switch (e.KeyData) {
                    case Keys.C:
                        ((RichTextBox)sender).Copy();
                        break;
                    case Keys.V:
                        ((RichTextBox)sender).Paste();
                        break;
                    case Keys.Z:
                        ((RichTextBox)sender).Undo();
                        break;
                    case Keys.Y:
                        ((RichTextBox)sender).Redo();
                        break;
                }
            }            
        }

Eugene Mikhaylov http://www.codelibrary.ru
Eugene Mikhaylov  Tuesday, August 25, 2009 7:59 AM
you should assing a OnKeyPress handler to each richTextBox at creation time. It should be something like that:

        private void action_handler(object sender, System.Windows.Forms.KeyEventArgs e)
        {            
            if (e.Control) {
                switch (e.KeyData) {
                    case Keys.C:
                        ((RichTextBox)sender).Copy();
                        break;
                    case Keys.V:
                        ((RichTextBox)sender).Paste();
                        break;
                    case Keys.Z:
                        ((RichTextBox)sender).Undo();
                        break;
                    case Keys.Y:
                        ((RichTextBox)sender).Redo();
                        break;
                }
            }            
        }

Eugene Mikhaylov http://www.codelibrary.ru
Eugene Mikhaylov  Tuesday, August 25, 2009 7:59 AM
HI,

thanks for ur reply,

I have one doubt,where can add this event to rich text box

Venkat ------------------------------------------------ -------------------------------------------------------------------------------- Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Sincerely, Venkat
Venkat Chilkuri  Tuesday, August 25, 2009 8:56 AM

hi,

we use this code for when button even fire


Venkat ------------------------------------------------ -------------------------------------------------------------------------------- Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Sincerely, Venkat
Venkat Chilkuri  Tuesday, August 25, 2009 10:18 AM

hi!

so, it works for you?


Eugene Mikhaylov http://www.codelibrary.ru
Eugene Mikhaylov  Tuesday, August 25, 2009 12:38 PM

You can use google to search for other answers

Custom Search

More Threads

• The small report screen doesn't work
• POLL: Windows vs. SQL Authentication
• NO BussinesRules Separation!
• bowwow10 - how does he do it?
• Forumbug
• Is there a way to ONLY install the source code...
• Update Web Refrence Problem (Issue Vision)
• Firewall/Proxy Question
• 'Error : Object reference not set an instance of an object' in DataGridView in Window
• Sample code not working in VB.NET ???