AccessDataSourceDesigner.DataFile 属性

定义

实现设计器属性,以便隐藏关联控件的 DataFile 属性。

public:
 property System::String ^ DataFile { System::String ^ get(); void set(System::String ^ value); };
public string DataFile { get; set; }
member this.DataFile : string with get, set
Public Property DataFile As String

属性值

一个 String,包含与 AccessDataSource 关联的数据文件的名称和路径。

示例

下面的代码示例演示如何使用 DataFile 属性在设计时显示与控件占位符中的 控件关联的 AccessDataSource Access 数据文件的名称和路径。

此代码示例是为 AccessDataSourceDesigner 类提供的一个更大示例的一部分。

// Generate design time markup.
public override string GetDesignTimeHtml()
{
    // Generate a design-time placeholder containing the 
    // DataFile and the ConnectionString properties.
    // Split the ConnectionString into segments so it doesn't make
    // placeholder too wide.
    string[] connectParts = GetConnectionString().Split(new char[] { ';' });
    string connectString = "  " + connectParts[0];

    for (int i = 1; i < connectParts.Length; i++)
        connectString += ";<br>  " + connectParts[i].Trim();

    return CreatePlaceHolderDesignTimeHtml(
        "DataFile: " + DataFile + "<br />" +
        "Connection string:<br />" + connectString);
}
' Generate design time markup.
Public Overrides Function GetDesignTimeHtml() As String
    ' Generate a design-time placeholder containing the 
    ' DataFile and the ConnectionString properties.
    ' Split the ConnectionString into segments so it doesn't make
    ' placeholder too wide.
    Dim connectParts() As String
    connectParts = GetConnectionString().Split((";").ToCharArray())
    Dim connectString As String
    connectString = "  " & connectParts(0)

    Dim i As Integer
    For i = 1 To connectParts.Length - 1
        connectString &= ";<br>  " & connectParts(i).Trim()
    Next

    Return CreatePlaceHolderDesignTimeHtml( _
        "DataFile: " & DataFile & "<br />" & _
        "Connection string:<br />" & connectString)
End Function

注解

DataFile将设计器中的 属性设置为包含要用于关联AccessDataSource控件的 Microsoft Access 数据库的 .mdb 文件的名称和路径。

适用于

另请参阅