DetailsViewDesigner.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 DetailsView besturingselement op het ontwerptijd weer te geven.
Overloads
| Name | Description |
|---|---|
| GetDesignTimeHtml() |
Hiermee haalt u de opmaak op die wordt gebruikt om het bijbehorende besturingselement op het ontwerptijd weer te geven. |
| GetDesignTimeHtml(DesignerRegionCollection) |
Hiermee haalt u de markering op die wordt gebruikt om het bijbehorende besturingselement op het ontwerptijd weer te geven en wordt een verzameling ontwerpregio's ingevuld. |
GetDesignTimeHtml()
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 DetailsView ontwerptijd weer te geven.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u de GetDesignTimeHtml methode in een klasse die is overgenomen van de DetailsViewDesigner klasse overschrijft om het uiterlijk van het besturingselement tijdens het DetailsView 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 waaruit is afgeleid DetailsView de NotSet of None waarde is, tekent de GetDesignTimeHtml blauwe stippelrand rond het besturingselement om de omvang beter zichtbaar te maken. Het uiterlijk van de runtime van het besturingselement wordt niet gewijzigd.
// Generate the design-time markup.
const string capTag = "caption";
const string trOpen = "tr><td colspan=2 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.
MyDetailsView myDV = (MyDetailsView)Component;
string markup = null;
int charX;
// Check if the border style should be changed.
if (myDV.BorderStyle == BorderStyle.NotSet ||
myDV.BorderStyle == BorderStyle.None)
{
BorderStyle oldBorderStyle = myDV.BorderStyle;
Unit oldBorderWidth = myDV.BorderWidth;
Color oldBorderColor = myDV.BorderColor;
// Set design-time properties and catch any exceptions.
try
{
myDV.BorderStyle = BorderStyle.Dashed;
myDV.BorderWidth = Unit.Pixel(3);
myDV.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.
myDV.BorderStyle = oldBorderStyle;
myDV.BorderWidth = oldBorderWidth;
myDV.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=2 align=center".
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=2 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 myDV As MyDetailsView = CType(Component, MyDetailsView)
Dim markup As String = Nothing
Dim charX As Integer
' Check if the border style should be changed.
If (myDV.BorderStyle = BorderStyle.NotSet Or _
myDV.BorderStyle = BorderStyle.None) Then
Dim oldBorderStyle As BorderStyle = myDV.BorderStyle
Dim oldBorderWidth As Unit = myDV.BorderWidth
Dim oldBorderColor As Color = myDV.BorderColor
' Set design-time properties and catch any exceptions.
Try
myDV.BorderStyle = BorderStyle.Dashed
myDV.BorderWidth = Unit.Pixel(3)
myDV.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.
myDV.BorderStyle = oldBorderStyle
myDV.BorderWidth = oldBorderWidth
myDV.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=2 align=center".
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
Eerst stelt de GetDesignTimeHtml() methode de AutoGenerateRows eigenschap van het DetailsView besturingselement truein op , als de Fields verzameling leeg is. Vervolgens GetDesignTimeHtml wordt de DataKeyNames verzameling van het GetDesignTimeHtml besturingselement ingesteld op een lege String matrix als het schema van de gegevensbron niet kan worden verkregen. Het vernieuwt het TypeDescriptor object om af te dwingen dat de PreFilterProperties methode wordt aangeroepen. Vervolgens wordt de basismethode aangeroepen om de opmaak te genereren.
Notities voor overnemers
Als u de GetDesignTimeHtml() methode overschrijft, moet u de basismethode aanroepen, omdat deze uiteindelijk, via verschillende onderdrukkingsniveaus, het DetailsView besturingselement of een kopie van het besturingselement aanroept om de opmaak te genereren.
Zie ook
Van toepassing op
GetDesignTimeHtml(DesignerRegionCollection)
Hiermee haalt u de markering op die wordt gebruikt om het bijbehorende besturingselement op het ontwerptijd weer te geven en wordt een verzameling ontwerpregio's ingevuld.
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
Parameters
- regions
- DesignerRegionCollection
Een DesignerRegionCollection waaraan u definities van de selecteerbare en klikbare regio's wilt toevoegen in de ontwerptijdweergave van het besturingselement.
Retouren
Een String met de opmaak die wordt gebruikt om de DetailsView 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 DetailsViewDesigner klasse om het uiterlijk van het besturingselement tijdens het DetailsView 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 DetailsView besturingselement de NotSet of None waarde is, tekent de GetDesignTimeHtml blauwe stippelrand rond het besturingselement om de omvang beter zichtbaar te maken. Het uiterlijk van de runtime van het besturingselement wordt niet gewijzigd.
// Generate the design-time markup.
const string capTag = "caption";
const string trOpen = "tr><td colspan=2 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.
MyDetailsView myDV = (MyDetailsView)Component;
string markup = null;
int charX;
// Check if the border style should be changed.
if (myDV.BorderStyle == BorderStyle.NotSet ||
myDV.BorderStyle == BorderStyle.None)
{
BorderStyle oldBorderStyle = myDV.BorderStyle;
Unit oldBorderWidth = myDV.BorderWidth;
Color oldBorderColor = myDV.BorderColor;
// Set design-time properties and catch any exceptions.
try
{
myDV.BorderStyle = BorderStyle.Dashed;
myDV.BorderWidth = Unit.Pixel(3);
myDV.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.
myDV.BorderStyle = oldBorderStyle;
myDV.BorderWidth = oldBorderWidth;
myDV.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=2 align=center".
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=2 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 myDV As MyDetailsView = CType(Component, MyDetailsView)
Dim markup As String = Nothing
Dim charX As Integer
' Check if the border style should be changed.
If (myDV.BorderStyle = BorderStyle.NotSet Or _
myDV.BorderStyle = BorderStyle.None) Then
Dim oldBorderStyle As BorderStyle = myDV.BorderStyle
Dim oldBorderWidth As Unit = myDV.BorderWidth
Dim oldBorderColor As Color = myDV.BorderColor
' Set design-time properties and catch any exceptions.
Try
myDV.BorderStyle = BorderStyle.Dashed
myDV.BorderWidth = Unit.Pixel(3)
myDV.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.
myDV.BorderStyle = oldBorderStyle
myDV.BorderWidth = oldBorderWidth
myDV.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=2 align=center".
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
Met DetailsViewDesigner.GetDesignTimeHtml de methode wordt de DetailsViewDesigner.GetDesignTimeHtml methode aangeroepen om de opmaak te genereren voor de ontwerptijdweergave van het DetailsView besturingselement. De DetailsViewDesigner.GetDesignTimeHtml methode wordt ook gevuld regions met een DesignerRegion object voor elke klikbare of selecteerbare regio van de ontwerptijdweergave.
Voor de DetailsVieweerste cel in elke rij kan worden geselecteerd. Alle cellen in de rijen kunnen worden geklikt.
Notities voor overnemers
Als u de GetDesignTimeHtml(DesignerRegionCollection) methode overschrijft, moet u de basismethode of de GetDesignTimeHtml() overbelasting aanroepen omdat ze uiteindelijk, via verschillende onderdrukkingsniveaus, het DetailsView besturingselement of een kopie van het besturingselement aanroepen om de markering te genereren.