次の方法で共有


HyperLinkDataBindingHandler.DataBindControl メソッド

指定されたコントロールにデータ連結します。

Overrides Public Sub DataBindControl( _
   ByVal designerHost As IDesignerHost, _   ByVal control As Control _)
[C#]
public override void DataBindControl(IDesignerHostdesignerHost,Controlcontrol);
[C++]
public: void DataBindControl(IDesignerHost* designerHost,Control* control);
[JScript]
public override function DataBindControl(
   designerHost : IDesignerHost,control : Control);

パラメータ

  • designerHost
    コントロールを含んでいるドキュメントの IDesignerHost
  • control
    データ連結する Control

解説

このメソッドは、 HyperLink コントロールの Text プロパティと href プロパティがデータ連結されているかどうかを確認します。プロパティがデータ連結されている場合、このメソッドは Text プロパティの値を "DataBound" に設定し、 href プロパティがデータ連結されている場合、このメソッドはプロパティの値をテキスト文字列に設定して、コントロールに有効なハイパーリンクの外観を持たせます。

使用例

[Visual Basic] CustomHyperLinkDataBindingHandler という名前のクラスを HyperLinkDataBindingHandler クラスから継承して作成するコードの例を次に示します。このコードは、 CustomHyperLink クラスの ImageUrl プロパティのデザイン時データ連結を解決します。これにより、このクラスがデザイン時にデータ連結された場合にこのプロパティのプレースホルダ テキストが表示されます。

 
' Create a class that derives from the 
' HyperLinkDataBindingHandler class. This
' will resolve data binding for the CustomHyperlink
' class at design time.
 Public Class CustomHyperLinkDataBindingHandler
   Inherits HyperLinkDataBindingHandler
   
   ' Override the DataBindControl method to set property
   ' values in the control's DataBindingCollection object
   ' at design time.
    Public Overrides Sub DataBindControl(designerHost As IDesignerHost, 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 

[C#, C++, JScript] C#、C++、および JScript のサンプルはありません。Visual Basic のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

HyperLinkDataBindingHandler クラス | HyperLinkDataBindingHandler メンバ | System.Web.UI.Design 名前空間