GridViewDesigner.GetDesignTimeHtml Methode

Definitie

Hiermee haalt u de opmaak op die wordt gebruikt om het bijbehorende GridView 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 GridView 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 GridViewDesigner klasse om het uiterlijk van het besturingselement tijdens het GridView 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 de GridView klasse de NotSet of None waarde heeft, tekent de GetDesignTimeHtml blauwe stippelrand rond het besturingselement om de omvang ervan 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=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

Opmerkingen

De GetDesignTimeHtml() methode doet het volgende:

  1. Hiermee stelt u de AutoGenerateColumns eigenschap van het besturingselement in op true, als de Columns eigenschap leeg is.

  2. Hiermee stelt u de DataKeyNames eigenschap van het besturingselement in op null, als het schema van de gegevensbron niet kan worden verkregen.

  3. Hiermee vernieuwt u het TypeDescriptor object om te forceren dat de PreFilterProperties methode moet worden aangeroepen.

  4. Roept de basismethode aan 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 GridView besturingselement of een kopie van het besturingselement aanroept om de markering 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 definitie van de selecteerbare en klikbare regio's in de ontwerptijdweergave van het besturingselement worden toegevoegd.

Retouren

Een String met de opmaak die wordt gebruikt om de GridView 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 GridViewDesigner klasse om het uiterlijk van het besturingselement tijdens het GridView 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 de GridView klasse de NotSet of None waarde heeft, tekent de GetDesignTimeHtml blauwe stippelrand rond het besturingselement om de omvang ervan 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=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

Opmerkingen

Met GetDesignTimeHtml(DesignerRegionCollection) de methode wordt de GetDesignTimeHtml() methode aangeroepen om de opmaak te genereren voor de ontwerptijdweergave van het GridView besturingselement. Het GetDesignTimeHtml(DesignerRegionCollection) wordt ook gevuld regions met een DesignerRegion object voor elke klikbare of selecteerbare regio van de ontwerptijdweergave.

Voor de GridVieweerste 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 GridView besturingselement of een kopie van het besturingselement aanroepen om de markeringen te genereren.

Zie ook

Van toepassing op