vb.net richtextbox table print
时间: 2023-11-29 07:03:15 浏览: 47
您可以使用以下代码将 RichTextBox 中的表格打印出来:
```vb.net
Dim tableStart As Integer = richTextBox1.Find("<table>")
Dim tableEnd As Integer = richTextBox1.Find("</table>")
If tableStart >= 0 AndAlso tableEnd >= 0 Then
Dim tableText As String = richTextBox1.Text.Substring(tableStart, tableEnd - tableStart + 8)
Dim tableDoc As New WebBrowser()
tableDoc.DocumentText = tableText
AddHandler tableDoc.DocumentCompleted, Sub(sender As Object, e As WebBrowserDocumentCompletedEventArgs)
DirectCast(sender, WebBrowser).Print()
End Sub
Else
MessageBox.Show("No table found in the RichTextBox.")
End If
```
此代码将在 RichTextBox 中查找包含 `<table>` 和 `</table>` 标签的文本,并将其加载到 WebBrowser 控件中,然后使用 Print 方法打印该控件的内容。如果 RichTextBox 中没有找到表格,则会显示一条消息框。
相关推荐
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)