GridViewDesigner.GetDesignTimeHtml Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Pobiera znaczniki używane do renderowania skojarzonej GridView kontrolki w czasie projektowania.
Przeciążenia
| GetDesignTimeHtml() |
Pobiera znaczniki używane do renderowania skojarzonej kontrolki w czasie projektowania. |
| GetDesignTimeHtml(DesignerRegionCollection) |
Pobiera znaczniki używane do renderowania skojarzonej kontrolki w czasie projektowania i wypełnia kolekcję regionów projektanta. |
GetDesignTimeHtml()
Pobiera znaczniki używane do renderowania skojarzonej kontrolki w czasie projektowania.
public:
override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml ();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String
Zwraca
Znacznik String zawierający znaczniki używane do renderowania GridView w czasie projektowania.
Przykłady
Poniższy przykład kodu pokazuje, jak zastąpić GetDesignTimeHtml metodę w klasie dziedziczonej GridViewDesigner z klasy w celu zmiany wyglądu GridView kontrolki w czasie projektowania. Przykład dodaje nowy pierwszy wiersz do siatki, aby zawierał Caption właściwość , jeśli jest zdefiniowana Caption . BorderStyle Jeśli właściwość kontrolki pochodzącej z GridView klasy ma NotSet wartość lubNone, rysuje niebieskie obramowanie kreskowane wokół kontrolki, GetDesignTimeHtml aby jego zakres był bardziej widoczny. Nie zmienia wyglądu kontrolki w czasie wykonywania.
// 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
Uwagi
Metoda GetDesignTimeHtml() wykonuje następujące czynności:
AutoGenerateColumns Ustawia właściwość kontrolki na
true, jeśli właściwość jest pustaColumns.DataKeyNames Ustawia właściwość kontrolki na
null, jeśli nie można uzyskać schematu źródła danych.Odświeża obiekt, TypeDescriptor aby wymusić PreFilterProperties wywołanie metody.
Wywołuje metodę podstawową w celu wygenerowania znaczników.
Uwagi dotyczące dziedziczenia
Jeśli zastąpisz GetDesignTimeHtml() metodę, pamiętaj, aby wywołać metodę podstawową, ponieważ w końcu przez kilka poziomów przesłonięcia wywołuje GridView kontrolkę lub kopię kontrolki w celu wygenerowania znaczników.
Zobacz też
Dotyczy
GetDesignTimeHtml(DesignerRegionCollection)
Pobiera znaczniki używane do renderowania skojarzonej kontrolki w czasie projektowania i wypełnia kolekcję regionów projektanta.
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
Parametry
- regions
- DesignerRegionCollection
Do DesignerRegionCollection której są dodawane definicje regionów możliwych do wyboru i klikalnych w widoku czasu projektowania kontrolki.
Zwraca
Znacznik String zawierający znaczniki używane do renderowania GridView w czasie projektowania.
Przykłady
Poniższy przykład kodu pokazuje, jak zastąpić GetDesignTimeHtml metodę w klasie dziedziczonej GridViewDesigner z klasy w celu zmiany wyglądu GridView kontrolki w czasie projektowania. Przykład dodaje nowy pierwszy wiersz do siatki, aby zawierał Caption właściwość , jeśli jest zdefiniowana Caption . BorderStyle Jeśli właściwość kontrolki pochodzącej z GridView klasy ma NotSet wartość lubNone, rysuje niebieskie obramowanie kreskowane wokół kontrolki, GetDesignTimeHtml aby jego zakres był bardziej widoczny. Nie zmienia wyglądu kontrolki w czasie wykonywania.
// 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
Uwagi
Metoda GetDesignTimeHtml(DesignerRegionCollection) wywołuje metodę GetDesignTimeHtml() , aby wygenerować znaczniki renderowania kontrolki GridView w czasie projektowania. Obiekt GetDesignTimeHtml(DesignerRegionCollection) jest regions również wypełniany obiektem DesignerRegion dla każdego możliwego do kliknięcia lub wybranego regionu renderowania w czasie projektowania.
GridViewW przypadku elementu pierwsza komórka w każdym wierszu można zaznaczyć. Wszystkie komórki w wierszach można kliknąć.
Uwagi dotyczące dziedziczenia
Jeśli zastąpisz metodę GetDesignTimeHtml(DesignerRegionCollection) , należy wywołać metodę podstawową lub GetDesignTimeHtml() przeciążenie, ponieważ w końcu przez kilka poziomów zastąpienia wywołaj GridView kontrolkę lub kopię kontrolki w celu wygenerowania znaczników.