HyperLinkDataBindingHandler.DataBindControl(IDesignerHost, Control) Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Разрешает привязку данных во время разработки для указанного элемента управления.
public:
override void DataBindControl(System::ComponentModel::Design::IDesignerHost ^ designerHost, System::Web::UI::Control ^ control);
public override void DataBindControl(System.ComponentModel.Design.IDesignerHost designerHost, System.Web.UI.Control control);
override this.DataBindControl : System.ComponentModel.Design.IDesignerHost * System.Web.UI.Control -> unit
Public Overrides Sub DataBindControl (designerHost As IDesignerHost, control As Control)
Параметры
- designerHost
- IDesignerHost
Документ IDesignerHost , содержащий элемент управления.
Примеры
В следующем примере кода создается класс с именем CustomHyperLinkDataBindingHandler, производным от HyperLinkDataBindingHandler класса. Она разрешает привязку данных во время разработки для ImageUrl свойства CustomHyperLink класса, чтобы замещающий текст отображался для свойства при его привязке к данным во время разработки.
// Derive a class from the HyperLinkDataBindingHandler. It will
// resolve data binding for the CustomHyperlink at design time.
public class CustomHyperLinkDataBindingHandler :
HyperLinkDataBindingHandler
{
// Override the DataBindControl to set property values in
// the DataBindingCollection at design time.
public override void DataBindControl(IDesignerHost designerHost,
Control control)
{
DataBindingCollection bindings =
((IDataBindingsAccessor)control).DataBindings;
DataBinding imageBinding = bindings["ImageUrl"];
// If Text is empty, supply a default value.
if (!(imageBinding == null))
{
CustomHyperLink hype = (CustomHyperLink)control;
hype.ImageUrl = "Image URL.";
}
// Call the base method to bind the control.
base.DataBindControl(designerHost, control);
} // DataBindControl
} // CustomHyperLinkDataBindingHandler
' Derive a class from the HyperLinkDataBindingHandler. It will
' resolve data binding for the CustomHyperlink at design time.
Public Class CustomHyperLinkDataBindingHandler
Inherits HyperLinkDataBindingHandler
' Override the DataBindControl to set property values in
' the DataBindingCollection at design time.
Public Overrides Sub DataBindControl( _
ByVal designerHost As IDesignerHost, ByVal control As Control)
Dim bindings As DataBindingCollection = _
CType(control, IDataBindingsAccessor).DataBindings
Dim imageBinding As DataBinding = bindings("ImageUrl")
If Not (imageBinding Is Nothing) Then
Dim hLink As CustomHyperLink = CType(control, CustomHyperLink)
hLink.ImageUrl = "Image URL."
End If
MyBase.DataBindControl(designerHost, control)
End Sub
End Class
Комментарии
Этот метод определяет, привязаны ли TextNavigateUrl свойства HyperLink элемента управления к данным. Text Если свойство привязано к данным, этот метод задает значение свойства "DataBound". NavigateUrl Если свойство привязано к данным, этот метод задает значение свойства текстовой строке, поэтому элемент управления будет иметь внешний вид рабочей гиперссылки.