VB.Net:openFileDialog中的字符串属性
我正在创建一个userControl,希望它有一个字符串属性,可以在设计时使用openFileDialog填充该属性 你知道,在VisualStudio属性文本框旁边有一个小“…”,这样你就可以根据需要浏览到一个文件 我想不出如何才能做到这一点。我感谢你的帮助 使用该类 在VB.Net:openFileDialog中的字符串属性,vb.net,properties,openfiledialog,Vb.net,Properties,Openfiledialog,我正在创建一个userControl,希望它有一个字符串属性,可以在设计时使用openFileDialog填充该属性 你知道,在VisualStudio属性文本框旁边有一个小“…”,这样你就可以根据需要浏览到一个文件 我想不出如何才能做到这一点。我感谢你的帮助 使用该类 在系统中添加参考。设计,然后使用如下代码: Imports System.ComponentModel Imports System.Drawing.Design Imports System.Windows.Forms.Des
系统中添加参考。设计
,然后使用如下代码:
Imports System.ComponentModel
Imports System.Drawing.Design
Imports System.Windows.Forms.Design
Public Class ucThingaMaBob
Private _FileName As String
' Add a Reference to System.Design
<EditorAttribute(GetType(FileNameEditor), GetType(UITypeEditor))>
Public Property FileName() As String
Get
Return _FileName
End Get
Set
_FileName = Value
End Set
End Property
End Class
导入System.ComponentModel
导入系统。绘图。设计
导入System.Windows.Forms.Design
公共类Uchingamabob
私有文件名为字符串
'添加对System.Design的引用
作为字符串的公共属性FileName()
得到
返回\u文件名
结束
设置
_文件名=值
端集
端属性
末级
现在,当您单击文件名条目中的“…”时,将出现一个OpenFileDialog。您能更具体地说明一下您尝试过的内容吗?Anthony,我不知道如何在此处正确插入代码段。。。我尝试了以下操作:Private ofd As Windows.Forms.OpenFileDialog Public Property SomeString()As Windows.Forms.OpenFileDialog Get Return of d End Get Set(ByVal value As Windows.Forms.OpenFileDialog)ofd=value End Set End Property我还尝试了IO.File而不是OpenFileDialog