FormViewDesigner.GetDesignTimeHtml Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee haalt u de opmaak op die wordt gebruikt om het bijbehorende besturingselement op het ontwerptijd weer te geven.
public:
override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String
Retouren
Een String met de opmaak die wordt gebruikt om de FormView ontwerptijd weer te geven.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u de GetDesignTimeHtml methode overschrijft in een klasse die wordt overgenomen van de FormViewDesigner klasse om het uiterlijk van het besturingselement tijdens het FormView ontwerp te wijzigen. In het voorbeeld wordt een nieuwe eerste rij aan het raster toegevoegd om de Caption eigenschap te bevatten, als de Caption eigenschap is gedefinieerd. Als de BorderStyle eigenschap van het besturingselement dat is afgeleid van het FormView besturingselement de NotSet of None waarde is, tekent de GetDesignTimeHtml blauwe stippelrand rond het besturingselement om de omvang beter zichtbaar te maken. In het voorbeeld wordt het uiterlijk van de runtime van het besturingselement niet gewijzigd.
// 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
Opmerkingen
Als er een itemsjabloon is gedefinieerd voor het FormView besturingselement, stelt de GetDesignTimeHtml methode de DataKeyNames verzameling van het besturingselement in op een lege String matrix als het schema voor de gegevensbron niet kan worden verkregen. Het GetDesignTimeHtml object wordt TypeDescriptor vernieuwd om een aanroep naar de PreFilterProperties methode af te dwingen. Vervolgens GetDesignTimeHtml wordt de basismethode aangeroepen om de opmaak te genereren.
Als er geen itemsjabloon is gedefinieerd voor het FormView besturingselement, roept GetEmptyDesignTimeHtml de GetDesignTimeHtml methode aan om markeringen te genereren die worden weergegeven in een tijdelijke aanduiding.
Notities voor overnemers
Als u de GetDesignTimeHtml() methode overschrijft, moet u de basismethode aanroepen, omdat deze uiteindelijk, via verschillende onderdrukkingsniveaus, het FormView besturingselement of een kopie van het FormView besturingselement aanroept om de opmaak te genereren.