禁用与richTextBox的任何交互(只是为了显示它) [英] Disabling any interaction with a richTextBox (it's just to show it)

查看:102
本文介绍了禁用与richTextBox的任何交互(只是为了显示它)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 richTextbox ,只是为了加载文本文件并查看它,同时循环滚动。

我不是希望用户能够添加,更改,选择,打开包装盒中的其他文件等。

我已禁用表单上的箭头键 ,所以你不能用它们切换到盒子。

到目前为止,我已经使用了以下内容:



For richTextBox的事件

- MouseClick ; MouseDoubleClick ; 的MouseDown ; 的MouseMove ; MouseUp ;

 Buttonx.Focus(); 



当我的应用程序运行时,我可以点击,按住并移动,没有任何事情发生。

这很好,但我发现当我使用鼠标中键或鼠标右键时(两次点击)而不使用左边的第一个,然后文本重新开始一次......?



看来我不能阻止用户使用其他按钮和问题是它对我的应用程序的功能有所帮助。



我尝试过的代码如下:

  if (e.Button == MouseButtons.Right)
// 和类似
如果(e.MousebuttonPressed == System.etc)





我也试图在盒子上方制作一层并让它看不见,但隐形也意味着没有互动... :(

如果我舔,它通过我的层!



没有任何效果,如果我试图左右键单击一个简单的弹出窗口,它只出现在左键单击..任何人知道一个解决方案来阻止盒子上的那些鼠标按钮吗?



对于我的总项目和(源)下载尝试,请参考:

以C#身份在初学者中创建NFO查看器 [ ^ ]:

解决方案

richtextbox是否具有启用属性或只读属性,这些是冻结内容的常用方法。

你想要做的是明确,无耻,不合理的虐待。保护您所显示的任何内容,比如选择或复制是对基本自然用户权利的最粗鲁的违反。在这种情况下,主要更宽松的是开发人员。用户在看到它时不会使用您的产品。你真正需要的只是readonly文件。



但是,制作不可选择的文件非常容易。它不能是Rich Text,但作为自定义渲染文本,这不是一个大问题。但是你需要从头开始,从 Control 类(或 UIElement for .NET)开始。



我只能添加解释:为什么你应该从头开始。这是因为.NET UI库的开发人员很清楚我在第一段中试图解释的内容。您需要的控件并不是真正需要的,这就是为什么它们不可用。



-SA


使用RichTextBox渲染输出。只是不要让它画到碎片上,而是换成图像。然后显示该图像而不是实际控件。



此功能可以构建为从UserControl,Control,Panel或任何看起来更实用的东西。

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... :(
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[^]:

解决方案

Does the richtextbox have an enabled property or a readonly property these are the usual way of freezing the content.


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


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.


这篇关于禁用与richTextBox的任何交互(只是为了显示它)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆