Solved

Disable Ctrl-A, Ctrl-C

Posted on 2009-05-07
5
546 Views
Last Modified: 2013-11-27
Hello Experts

I need to disable the ability of users to select and copy text in a Rich Text Control using Ctrl-A and Ctrl-C.

How do I go about this?

Many thanks
0
Comment
Question by:jindalee
  • 2
5 Comments
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
Comment Utility
Set the ShortCutsEnabled property to False.

Wayne
0
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
Comment Utility
To disable only Ctrl+A and Ctrl+C, you will need to intercept the KeyPresses.....
    Private Sub RichTextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown
 

        If e.Control Then

            If e.KeyCode = Keys.C Or e.KeyCode = Keys.A Then

                e.Handled = True

            End If

        End If
 

    End Sub

Open in new window

0
 
LVL 5

Expert Comment

by:rendaduiyan
Comment Utility

        public bool PreFilterMessage(ref Message m)

        {

            if (m.Msg == WM_KEYDOWN)

            {

                return HandleKeys((Keys)((int)m.WParam) & Keys.KeyCode);

            }

            return false;

        }

        public bool HandleKeys(Keys keycode)

        {

            bool ret = true;

            switch (keycode)

            {

                case Keys.Alt | Keys.F4: this.Close();break;

                case Keys.Alt | Keys.N: MoveInList(Direction.FORWARD); break;

                case Keys.Alt | Keys.B: MoveInList(Direction.BACKWORD); break;

                //.........

                default: ret = false; break;

            }

            return ret;

        }

Open in new window

0
 
LVL 1

Author Closing Comment

by:jindalee
Comment Utility
Thank you webtubbs. Worked first time.

BTW. It is good to see a moderator remind a contributor that a submission should add value to the question and should also address specifics such as programming language. Too many times you see a question asking for a response in (e.g.) VB.Net only to find loads of answers in some other language.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now