AccessDataSourceDesigner.DataFile 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
實作設計工具屬性,以遮蔽關聯控制項的 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檔案的名稱和路徑。