如何复制单独选择的RichTextBox的内容?

编程入门 行业动态 更新时间:2024-10-20 15:49:24
本文介绍了如何复制单独选择的RichTextBox的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好,我有42个RichTextBoxes(RTB),我想将ContextMenuStrip添加到它们中的每一个(已经完成),但是我遇到的问题是当应用程序正在运行并且ContextMenuItem为复制"时例如,当我单击它时,我只想复制任何一个RTB的内容,就只能使其复制一个RTB的上下文. 因此,正如我提到的,我有42个实时出价工具,但是我在获取重点实时出价工具的内容时遇到了麻烦.下面的代码只是复制1个RTB,而当我在另一个RTB上复制时,它将复制RTB1的内容. 我最初是这样开始的,但仅适用于一个RTB,而当我在下面的代码中添加多个代码时,这简直是一场灾难..

Hello, I have 42 RichTextBoxes (RTBs) and I would like to add my ContextMenuStrip to each of them (which I have already done), but the problem I am having is when the application is running and the ContextMenuItem "Copy" for example is clicked, I can only make it copy the context of one of the RTBs, when I would like it to copy the contents of any individual one. So as I mentioned, I have 42 RTBs, but I am having trouble getting the contents of the focused RTB. The below code is just copying the 1 RTB and when I Copy on another RTB, it copies the contents of RTB1. I originally started out with like so, but is just for the one RTB and when I add more than one in the code below it''s even more of a disaster..

Private Sub Copy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Copy.Click RichTextBox1.Copy() End Sub

我尝试使用此功能,但不确定如何将复制功能添加到其中:

I tried using this, but I was not sure how to add the copy function into it:

Private Sub Copy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Copy.Click Try For Each itm As Control In EnumerateAllControls(Me) For Each c As Control In itm.Controls If TypeOf c Is RichTextBox Then ****NOT SURE WHAT CODE TO PUT HERE..**** End If Next Next Catch ex As Exception MsgBox(ex.Message) End Try End Sub

因此,如果任何人都可以帮助我的Copy ContextMenuItem专注于以用户为中心的RTB,我将不胜感激! :)

So If anyone can help my Copy ContextMenuItem to focus on the user focused RTB, I would greatly appreciate it! :)

推荐答案

您将执行以下操作 You would do something like this if TypeOf c is RichTextBox then c.Copy end if

但这只会将其复制到剪贴板,并将被其他Richtextbox中的数据覆盖.

But this only copies it to the clipboard and will be overwritten with the data from the other Richtextboxs.

更多推荐

如何复制单独选择的RichTextBox的内容?

本文发布于:2023-10-16 16:29:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1498102.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内容   RichTextBox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!