ListControlDesigner.GetDesignTimeHtml Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the HTML that is used to represent the control at design time.
public:
override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml ();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String
Returns
A String containing the markup used to render the control derived from the ListControl at design time.
Examples
The following code example overrides the GetDesignTimeHtml method to customize the markup that is displayed for the associated control on a design surface. If the BackColor property is not defined for the associated control, it is set to Gainsboro
, and the control is displayed with that background color. After this is done, the base implementation of the GetDesignTimeHtml method is called.
This code example is part of a larger example provided for the ListControlDesigner class.
// Create the markup to display the control on the design surface.
public override string GetDesignTimeHtml()
{
string designTimeMarkup = null;
// Create variables to access the control
// item collection and back color.
ListItemCollection items = simpleRadioButtonList.Items;
Color oldBackColor = simpleRadioButtonList.BackColor;
// Check the property values and render the markup
// on the design surface accordingly.
try
{
if (oldBackColor == Color.Empty)
simpleRadioButtonList.BackColor = Color.Gainsboro;
if (changedDataSource)
items.Add("Updated to a new data source: " +
DataSource + ".");
// Call the base method to generate the markup.
designTimeMarkup = base.GetDesignTimeHtml();
}
catch (Exception ex)
{
// Catch any exceptions that occur.
designTimeMarkup = GetErrorDesignTimeHtml(ex);
}
finally
{
// Set the properties back to their original state.
simpleRadioButtonList.BackColor = oldBackColor;
items.Clear();
}
return designTimeMarkup;
} // GetDesignTimeHtml
' Create the markup to display the control on the design surface.
Public Overrides Function GetDesignTimeHtml() As String
Dim designTimeHtml As String = String.Empty
' Create variables to access the control's
' item collection and back color.
Dim items As ListItemCollection = simpleRadioButtonList.Items
Dim oldBackColor As Color = simpleRadioButtonList.BackColor
' Check the property values and render the markup
' on the design surface accordingly.
Try
If (Color.op_Equality(oldBackColor, Color.Empty)) Then
simpleRadioButtonList.BackColor = Color.Gainsboro
End If
If (changedDataSource) Then
items.Add( _
"Updated to a new data source: " & DataSource & ".")
End If
designTimeHtml = MyBase.GetDesignTimeHtml()
Catch ex As Exception
' Catch any exceptions that occur.
MyBase.GetErrorDesignTimeHtml(ex)
Finally
' Set the properties back to their original state.
simpleRadioButtonList.BackColor = oldBackColor
items.Clear()
End Try
Return designTimeHtml
End Function ' GetDesignTimeHtml
Remarks
If the associated control derived from the ListControl object is data-bound, the GetDesignTimeHtml method clears the Items collection and adds a String message indicating the control is data-bound. If the associated control is not data-bound and the Items collection is empty, the GetDesignTimeHtml adds a String message indicating the control is unbound. Then, the GetDesignTimeHtml calls its base method to generate the markup.