Dela via


RemoteBindableComponent.BindingContext Property (2007 System)

Gets or sets the System.Windows.Forms.BindingContext for the component.

Namespace:  Microsoft.VisualStudio.Tools.Office
Assembly:  Microsoft.Office.Tools.v9.0 (in Microsoft.Office.Tools.v9.0.dll)

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public Property BindingContext As BindingContext
'Usage
Dim instance As RemoteBindableComponent 
Dim value As BindingContext 

value = instance.BindingContext

instance.BindingContext = value
[BrowsableAttribute(false)]
public BindingContext BindingContext { get; set; }
[BrowsableAttribute(false)]
public:
virtual property BindingContext^ BindingContext {
    BindingContext^ get () sealed;
    void set (BindingContext^ value) sealed;
}
public final function get BindingContext () : BindingContext 
public final function set BindingContext (value : BindingContext)

Property Value

Type: System.Windows.Forms.BindingContext

Implements

IBindableComponent.BindingContext

Remarks

The System.Windows.Forms.BindingContext object of a component is used to return a single BindingManagerBase object for all data-bound components contained by the component. The BindingManagerBase object keeps all components that are bound to the same data source synchronized. For example, setting the Position property of the BindingManagerBase specifies the item in the underlying list that all data-bound components point to.

Examples

The following code example demonstrates a handler for the Click event of a Button. When the Button is clicked, the example uses the BindingContext property to display the next data-bound item in a NamedRange. This code example is part of a larger code example provided for the RemoteBindableComponent class.

' Displays the next data item in the NamedRange. 
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) _
    Handles button1.Click

    If Not (namedRange1.BindingContext Is Nothing) Then 
        Dim bindingManager1 As BindingManagerBase = _
            namedRange1.BindingContext(ds, "Customers")

        ' Display the next item. 
        If bindingManager1.Position < bindingManager1.Count - 1 Then
            bindingManager1.Position += 1

            ' Display the first item. 
        Else
            bindingManager1.Position = 0
        End If 
    End If 
End Sub
// Displays the next data item in the NamedRange. 
void button1_Click(object sender, EventArgs e)
{
    if (namedRange1.BindingContext != null)
    {
        BindingManagerBase bindingManager1 =
            namedRange1.BindingContext[ds, "Customers"];

        // Display the next item. 
        if (bindingManager1.Position < bindingManager1.Count - 1)
        {
            bindingManager1.Position++;
        }

        // Display the first item. 
        else
        {
            bindingManager1.Position = 0;
        }
    }
}

.NET Framework Security

See Also

Reference

RemoteBindableComponent Class

RemoteBindableComponent Members

Microsoft.VisualStudio.Tools.Office Namespace