无法从选定的选项卡中获取RichTextbox

发布于 2025-01-24 14:02:34 字数 569 浏览 5 评论 0原文

我的程序快要完成了,这是一个多标签的记事本,我无法上班保存“ Active”选项卡的RichTextbox。

ScreenShot

First Tab具有一个名为“ BlackText”的RichTextbox,但其他Tab是通过单击“新的”而动态创建的。 ”。

new tab + new tab + new rtb(picture)

我在Google中尝试了许多答案。 我会授予您为我修复的选项([[下载there.rar] [3]),然后将其退还给我,,因为我白天和黑夜都在涉足一个星期随着挫败感的增加,这将不胜感激。

谢谢, 链接

My program is almost finished, which is a multi-tabbed Notepad, and i can't get to work saving the RichTextBox of the active tab.

Screenshot

First tab has a RichTextBox called "BLACKTEXT" but the others are created dynamically by clicking "New".

new tab + new rtb (picture)

When hitting 'Save', the RichTextBox of the SelectedTab has to be saved.
I tried many answers in Google. I'll grant you the option to fix it for me ([download here.rar][3]) and return it back to me, because i've been dabbling around day and night for a week with increasing frustration and that would be greatly appreciated.

Thanks,
linkings

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

李白 2025-01-31 14:02:34

此代码将从当前选择的tabPage tabcontrol1

Dim selectedRichTextBox = TableControl1.SelectedTab.
                                        Controls.
                                        OfType(Of RichTextBox)().
                                        Single()

This code will get the one and only RichTextBox control from the currently selected TabPage of TabControl1:

Dim selectedRichTextBox = TableControl1.SelectedTab.
                                        Controls.
                                        OfType(Of RichTextBox)().
                                        Single()
情定在深秋 2025-01-31 14:02:34

我无法为您修理,但也许我可以帮忙。您要保存RichTextbox控件或RichTextbox控件的内容吗?如果您要保存的是RichTtextbox控件的内容,请使用RichTextbox的.rtf属性并将其写入要创建的文件:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    With SaveFileDialog1
        If .ShowDialog() = Windows.Forms.DialogResult.OK Then
            Call SaveRTF(.FileName)
        End If
    End With
End Sub

Private Sub SaveRTF(ByVal pSelectedPath As String)
    Dim newFile As String = pSelectedPath & ".rtf"
    File.AppendAllText(newFile, RichTextBox1.Rtf)
End Sub

I can't fix it for you but maybe I could help. Do you want to save the richtextbox control or the content of the richtextbox control? If it's the content of richttextbox control that you want to save, use the .rtf property of the RichTextBox and write it on the file to be created:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    With SaveFileDialog1
        If .ShowDialog() = Windows.Forms.DialogResult.OK Then
            Call SaveRTF(.FileName)
        End If
    End With
End Sub

Private Sub SaveRTF(ByVal pSelectedPath As String)
    Dim newFile As String = pSelectedPath & ".rtf"
    File.AppendAllText(newFile, RichTextBox1.Rtf)
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文