简体   繁体   English

选择RichTextBox时创建OpenFileDialog吗?

[英]Create OpenFileDialog when RichTextBox selected?

In my application, a list of fields is read from a database, and then rendered in a TabControlPage. 在我的应用程序中,从数据库中读取字段列表,然后将其呈现在TabControlPage中。 Each field has a Control of a specific type, one of which is a RichTextBox. 每个字段都有一个特定类型的控件,其中一个是RichTextBox。

What I need, is when the user selects the RichTextBox, an OpenFileDialog should appear, allowing the user to select a file. 我需要的是,当用户选择RichTextBox时,应出现一个OpenFileDialog,允许用户选择一个文件。 The RichTextBox should then display the full path + filename(eg. C:/files/excel/thing.xlsx) in the form of a hyperlink. 然后,RichTextBox应以超链接的形式显示完整路径+文件名(例如C:/files/excel/thing.xlsx)。

Currently, you can type in the path+filename into the RichTextBox and it will automatically be made into a hyperlink. 当前,您可以在RichTextBox中输入path + filename,它将自动成为超链接。

Any suggestions, or perhaps reference material you can give me? 您有什么建议或参考资料可以给我吗?

You can attach something like this to the Enter event on your RichTextBox: 您可以将以下内容附加到RichTextBox的Enter事件上:

Dim dialog As New OpenFileDialog()
Dim result As DialogResult = dialog.ShowDialog()
If result = Windows.Forms.DialogResult.OK Then
    RichTextBox1.Text = dialog.FileName
End If

This is not turning it into a hyperlink for me, but it sounds like you have that part handled? 对于我来说,这并不是将其转变为超链接,但是听起来您已经处理了那部分?

edited as per Lars' comment. 根据Lars的评论进行编辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM