FormViewDesigner.GetDesignTimeHtml Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan markup yang digunakan untuk merender kontrol terkait pada waktu desain.
public:
override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml ();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String
Mengembalikan
yang String berisi markup yang digunakan untuk merender pada FormView waktu desain.
Contoh
Contoh kode berikut menunjukkan cara mengambil GetDesignTimeHtml alih metode di kelas yang diwarisi dari FormViewDesigner kelas untuk mengubah tampilan FormView kontrol pada waktu desain. Contoh menambahkan baris pertama baru ke kisi untuk berisi Caption properti , jika Caption ditentukan. BorderStyle Jika properti kontrol yang berasal dari FormView adalah NotSet nilai atau None , properti GetDesignTimeHtml akan menggambar batas putus-putus biru di sekitar kontrol agar jangkauannya lebih terlihat. Contoh tidak mengubah tampilan run-time kontrol.
// Generate the design-time markup.
const string capTag = "caption";
const string trOpen = "tr><td colspan=9 align=center";
const string trClose = "td></tr";
public override string GetDesignTimeHtml()
{
// Make the full extent of the control more visible in the designer.
// If the border style is None or NotSet, change the border to
// a wide, blue, dashed line. Include the caption within the border.
MyFormView myGV = (MyFormView)Component;
string markup = null;
int charX;
// Check if the border style should be changed.
if (myGV.BorderStyle == BorderStyle.NotSet ||
myGV.BorderStyle == BorderStyle.None)
{
BorderStyle oldBorderStyle = myGV.BorderStyle;
Unit oldBorderWidth = myGV.BorderWidth;
Color oldBorderColor = myGV.BorderColor;
// Set the design-time properties and catch any exceptions.
try
{
myGV.BorderStyle = BorderStyle.Dashed;
myGV.BorderWidth = Unit.Pixel(3);
myGV.BorderColor = Color.Blue;
// Call the base method to generate the markup.
markup = base.GetDesignTimeHtml();
}
catch (Exception ex)
{
markup = GetErrorDesignTimeHtml(ex);
}
finally
{
// Restore the properties to their original settings.
myGV.BorderStyle = oldBorderStyle;
myGV.BorderWidth = oldBorderWidth;
myGV.BorderColor = oldBorderColor;
}
}
else
{
// Call the base method to generate the markup.
markup = base.GetDesignTimeHtml();
}
// Look for a <caption> tag.
if ((charX = markup.IndexOf(capTag)) > 0)
{
// Replace the first caption with
// "tr><td colspan=9 align=center".
// It is okay if the colspan exceeds the
// number of columns in the table.
markup = markup.Remove(charX,
capTag.Length).Insert(charX, trOpen);
// Replace the second caption with "td></tr".
if ((charX = markup.IndexOf(capTag, charX)) > 0)
markup = markup.Remove(charX,
capTag.Length).Insert(charX, trClose);
}
return markup;
} // GetDesignTimeHtml
' Generate the design-time markup.
Private Const capTag As String = "caption"
Private Const trOpen As String = "tr><td colspan=9 align=center"
Private Const trClose As String = "td></tr"
Public Overrides Function GetDesignTimeHtml() As String
' Make the full extent of the control more visible in the designer.
' If the border style is None or NotSet, change the border to
' a wide, blue, dashed line. Include the caption within the border.
Dim myGV As MyFormView = CType(Component, MyFormView)
Dim markup As String = Nothing
Dim charX As Integer
' Check if the border style should be changed.
If (myGV.BorderStyle = BorderStyle.NotSet Or _
myGV.BorderStyle = BorderStyle.None) Then
Dim oldBorderStyle As BorderStyle = myGV.BorderStyle
Dim oldBorderWidth As Unit = myGV.BorderWidth
Dim oldBorderColor As Color = myGV.BorderColor
' Set the design-time properties and catch any exceptions.
Try
myGV.BorderStyle = BorderStyle.Dashed
myGV.BorderWidth = Unit.Pixel(3)
myGV.BorderColor = Color.Blue
' Call the base method to generate the markup.
markup = MyBase.GetDesignTimeHtml()
Catch ex As Exception
markup = GetErrorDesignTimeHtml(ex)
Finally
' Restore the properties to their original settings.
myGV.BorderStyle = oldBorderStyle
myGV.BorderWidth = oldBorderWidth
myGV.BorderColor = oldBorderColor
End Try
Else
' Call the base method to generate the markup.
markup = MyBase.GetDesignTimeHtml()
End If
' Look for a <caption> tag.
charX = markup.IndexOf(capTag)
If charX > 0 Then
' Replace the first caption with
' "tr><td colspan=9 align=center".
' It is okay if the colspan exceeds the
' number of columns in the table.
markup = markup.Remove(charX, _
capTag.Length).Insert(charX, trOpen)
' Replace the second caption with "td></tr".
charX = markup.IndexOf(capTag, charX)
If charX > 0 Then
markup = markup.Remove(charX, _
capTag.Length).Insert(charX, trClose)
End If
End If
Return markup
End Function ' GetDesignTimeHtml
Keterangan
Jika templat item telah ditentukan untuk FormView kontrol, GetDesignTimeHtml metode mengatur DataKeyNames kumpulan kontrol ke array kosong String jika skema untuk sumber data tidak dapat diperoleh. menyegarkan GetDesignTimeHtmlTypeDescriptor objek untuk memaksa panggilan ke PreFilterProperties metode . kemudian GetDesignTimeHtml memanggil metode dasar untuk menghasilkan markup.
Jika tidak ada templat item yang ditentukan untuk FormView kontrol, GetDesignTimeHtml memanggil GetEmptyDesignTimeHtml metode untuk menghasilkan markup yang dirender ke tempat penampung.
Catatan Bagi Inheritor
Jika Anda mengambil GetDesignTimeHtml() alih metode , pastikan untuk memanggil metode dasar karena pada akhirnya, melalui beberapa tingkat penimpaan, panggilan pada FormView kontrol atau salinan FormView kontrol untuk menghasilkan markup.
Berlaku untuk
Lihat juga
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk