有什么方法可以禁止在备忘录控件中选择文本吗?
有什么方法可以禁止在备忘录控件中选择文本,因为这非常烦人。
该备忘录是只读的。
Is there any way to disable selecting of text in a memo control because it's very anoying.
The memo is Read Only.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为你应该重新考虑一下。我意识到您的控件以只读模式使用,但是,如果最终用户希望复制文本的一部分怎么办?然后他需要能够选择有问题的部分。
不过,如果您确定需要禁用每种选择,最简单的方法是使用
TRichEdit
而不是TMemo
,然后简单地执行I think you should rethink. I realise that your control is used in read-only mode, but still, what if the end user wishes to copy a part of the text? Then he needs to be able to select the part in question.
Still, if you are certain that you need to disable every kind of selection, the easiest approach is to use a
TRichEdit
instead of theTMemo
, and do simply您还可以使用 onMouseUp 事件
,但是,这不会停止使用键盘进行选择。
或者您也可以使用 onEnter,只需将焦点更改到窗体上的另一个控件。
You could also use the onMouseUp event
But, that doesn't stop selecting with the keyboard..
or you could also use the onEnter, and just change the focus to another control on your form.
我一直在玩 TRichEdit 和 TMemo,直到无聊到流泪。是的,您可以对对象进行一些事件处理技巧,但这仍然不是所需的效果 - 并且光标最终会在某处闪烁。所以我能找到的最好的办法就是使用 TLabel。我正在使用 Borland C++ Builder 6,并且 \n 使用 TLabel 的内联文本字符串正确翻译。所以,
工作得很好。我没有尝试从文件中读入,但我确信如果流与所看到的完全一样,它也会起作用。由于您必须输入或阅读要显示的文本 - 这应该可以很好地工作,而不是为每行使用一堆 TLabel。如果您担心自动换行,则必须单独处理该部分。如果它是静态的,那么就像我在示例中所做的那样手动完成。我当然希望这会有所帮助或至少给出一个想法......
I played around with TRichEdit and TMemo until I was bored to tears. Yes, you can do a few tricks with event handling on the object, but it still is not the desired effect - and the cursor winds up blinking somewhere. So the best thing I could find was to use TLabel. I'm using Borland C++ Builder 6, and the \n is translated correctly with inline text strings for TLabel. So,
Works just fine. I haven't tried to read in from a file, but I'm certain that if the stream were exactly as seen it would also work. Since you are going to have to enter or read in the text you want displayed anyway - this should work well instead of using a bunch of TLabels for each line. If you have a concern for word wrapping, you will have to process that portion separately. If it static, then just do it by hand like I did in the example. I sure hope this helps or at least gives an idea...
据我了解,您实际上想使用备忘录作为标签(有时它确实有意义)。
当我需要使用 TcxMemo(来自 DeveloperExpress 的备忘录组件)作为标签时,我使用这样简单的过程:
As i understand you would like to use memo as label actually (and sometimes it really have sense).
When i need to use TcxMemo (memo component from DeveloperExpress) as label i use such simple procedure: