GridViewDesigner.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 GridView pada waktu desain.
Overload
| Nama | Deskripsi |
|---|---|
| GetDesignTimeHtml() |
Mendapatkan markup yang digunakan untuk merender kontrol terkait pada waktu desain. |
| GetDesignTimeHtml(DesignerRegionCollection) |
Mendapatkan markup yang digunakan untuk merender kontrol terkait pada waktu desain dan mengisi kumpulan wilayah desainer. |
GetDesignTimeHtml()
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 GridView pada waktu desain.
Contoh
Contoh kode berikut menunjukkan cara mengambil alih GetDesignTimeHtml metode di kelas yang diwarisi dari GridViewDesigner kelas untuk mengubah tampilan GridView 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 GridView kelas memiliki NotSet nilai atau None , GetDesignTimeHtml gambar batas putus-putus biru di sekitar kontrol untuk membuat tingkatnya lebih terlihat. Ini 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.
MyGridView myGV = (MyGridView)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 MyGridView = CType(Component, MyGridView)
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
Metode ini GetDesignTimeHtml() melakukan hal berikut:
AutoGenerateColumns Mengatur properti kontrol ke
true, jika Columns properti kosong.DataKeyNames Mengatur properti kontrol ke
null, jika skema sumber data tidak dapat diperoleh.Menyegarkan TypeDescriptor objek untuk memaksa metode dipanggil PreFilterProperties .
Memanggil metode dasar untuk menghasilkan markup.
Catatan Bagi Inheritor
Jika Anda mengambil GetDesignTimeHtml() alih metode , pastikan untuk memanggil metode dasar, karena pada akhirnya, melalui beberapa tingkat penimpaan, panggilan pada GridView kontrol atau salinan kontrol untuk menghasilkan markup.
Lihat juga
Berlaku untuk
GetDesignTimeHtml(DesignerRegionCollection)
Mendapatkan markup yang digunakan untuk merender kontrol terkait pada waktu desain dan mengisi kumpulan wilayah desainer.
public:
override System::String ^ GetDesignTimeHtml(System::Web::UI::Design::DesignerRegionCollection ^ regions);
public override string GetDesignTimeHtml(System.Web.UI.Design.DesignerRegionCollection regions);
override this.GetDesignTimeHtml : System.Web.UI.Design.DesignerRegionCollection -> string
Public Overrides Function GetDesignTimeHtml (regions As DesignerRegionCollection) As String
Parameter
- regions
- DesignerRegionCollection
DesignerRegionCollection Definisi wilayah yang dapat dipilih dan dapat diklik dalam tampilan waktu desain kontrol ditambahkan.
Mengembalikan
Yang String berisi markup yang digunakan untuk merender GridView pada waktu desain.
Contoh
Contoh kode berikut menunjukkan cara mengambil alih GetDesignTimeHtml metode di kelas yang diwarisi dari GridViewDesigner kelas untuk mengubah tampilan GridView 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 GridView kelas memiliki NotSet nilai atau None , GetDesignTimeHtml gambar batas putus-putus biru di sekitar kontrol untuk membuat tingkatnya lebih terlihat. Ini 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.
MyGridView myGV = (MyGridView)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 MyGridView = CType(Component, MyGridView)
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
Metode ini GetDesignTimeHtml(DesignerRegionCollection) memanggil GetDesignTimeHtml() metode untuk menghasilkan markup untuk penyajian GridView waktu desain kontrol. juga GetDesignTimeHtml(DesignerRegionCollection) diisi regions dengan DesignerRegion objek untuk setiap wilayah yang dapat diklik atau dipilih dari penyajian waktu desain.
GridViewUntuk , sel pertama di setiap baris dapat dipilih; semua sel dalam baris dapat diklik.
Catatan Bagi Inheritor
Jika Anda mengambil GetDesignTimeHtml(DesignerRegionCollection) alih metode , pastikan untuk memanggil metode dasar atau GetDesignTimeHtml() kelebihan beban, karena akhirnya, melalui beberapa tingkat penimpaan, panggil GridView kontrol atau salinan kontrol untuk menghasilkan markup.