Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# key Mouse RichTextBox , +
I'm using a richTextbox, just to load a textfile and view it, while looped scrolling.
I don't want users to be able to add, change, select, open other files in the box, etc.
I disabled the arrow keys on the Form, so you can't use them to switch to the Box.
So far I've used the following:
 
For the Events of the richTextBox:
- MouseClick; MouseDoubleClick; MouseDown; MouseMove; MouseUp;
Buttonx.Focus();
When my application runs, I can click, hold down and move, without anything happening.
That's good, but I discovered that when I use the middle mouse button or right mouse button (both click) without using the left first, then the text starts over again just once...?
 
It seems I can't block users from using the other buttons and the problem is it does something to the functionality of my application.
 
I tried code like:
if (e.Button==MouseButtons.Right)
// AND somthing like
if (e.MousebuttonPressed==System.etc)
 
I also tried to make a layer above the box and make it invisible, but invisible means not interactive as well... Frown | :(
If I click, it goes through my layer!
 
Nothing worked, if I tried to make a simple popup on left and right click, it only appears on left click.. Anyone that knows a solution to block those mousepresses on the box?
 
For my total Project and (source) downloads to try, refer to:
Creating a NFO Viewer in C# as a beginner[^]:
Posted 22-Jan-13 23:07pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Does the richtextbox have an enabled property or a readonly property these are the usual way of freezing the content.
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 23-Jan-13 4:18am
   
Unfortunately, this is not what OP wants. Look thoroughly. It should not be selectable, the user should not be able to copy it, etc.
 
Please see my answer where I explain what I think about it. Actually, normally it should be read-only and that's it...
This is the second time I see such request... doh!
 
—SA
DarkTyranno at 23-Jan-13 4:36am
   
Yes, ReadOnly = True and Enabled must be True, because disabling the richTextBox prevents some custom settings to work.
I know it's not the regular setting for applications, but I make a NFO Viewer which I put with releases. I just want to view the text as ending credits in a movie. I don't get why people often hammer on others who want to use settings that are abnormal. This is no real application which end users have to install and use, it's just a standalone executable which reads the file. Please refer to my project in question if you want to get why I want to use these settings ;)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

What you want to do is clear, shameless, unreasonable abuse. Protecting anything you show from, say, selecting or copying is the most rude violation of elementary natural user's right. The main looser in such cases is the developer. Users won't use your product when they see it. All you really need is the readonly document.
 
However, making non-selectable document is quite easy. It cannot be Rich Text, but as a custom-rendered text it's not a big problem. But you will need to do it totally from scratch, starting from Control class (or UIElement for .NET).
 
I can only add the explanation: why you should start from scratch. This is because developers of .NET UI libraries understand well what I tried to explain in the first paragraph. The controls you thing you need are not really needed, that's why they are not available.
 
—SA
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Use the RichTextBox to render your output. Just don't let it draw to the scree, but to an image instead. Then display that image instead of an actual control.
 
This functionality can be built into something derived from UserControl, Control, Panel or whatever seems more practical for you.
  Permalink  
Comments
DarkTyranno at 23-Jan-13 6:33am
   
It sounds hard. I'm working with C# for just some weeks, so I don't really get how to do that. But the idea sounds great, I can try to do some research for this option. Maybe some other options will appear, I go try it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 105
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 23 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100