BindingNavigator クラスとは? わかりやすく解説

BindingNavigator クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

フォーム上にあるデータバインドされたコントロール移動および操作ユーザー インターフェイス (UI) を表します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

<ComVisibleAttribute(True)> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
Public Class BindingNavigator
    Inherits ToolStrip
    Implements ISupportInitialize
Dim instance As BindingNavigator
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
public class BindingNavigator : ToolStrip,
 ISupportInitialize
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
public ref class BindingNavigator : public
 ToolStrip, ISupportInitialize
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
public class BindingNavigator extends ToolStrip
 implements ISupportInitialize
ComVisibleAttribute(true) 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
public class BindingNavigator extends
 ToolStrip implements ISupportInitialize
解説解説

BindingNavigator コントロールは、フォーム上のデータ間を移動したり、データ操作したりするための標準的な方法表します多く場合BindingNavigator は、BindingSource コントロール組み合わせてフォーム上のデータ レコード間を移動したり、レコード操作したりするために使用します。この場合、BindingSource プロパティが、データ ソースとして機能する関連System.Windows.Forms.BindingSource コンポーネント設定されます。

既定では、BindingNavigator コントロールユーザー インターフェイス (UI) は、一連の ToolStrip ボタンテキスト ボックス、および最もよく使用されるデータ関連操作 (データ追加データ削除データ間の移動など) を表す静的テキスト要素構成されます。これらの各コントロールは、BindingNavigator コントロール関連するメンバ通じて取得または設定できますまた、これらのメンバは、プログラム上で同じ機能を果たす BindingSource クラスメンバ一対一対応してます。次の表に、その対応を示します

UI コントロール

BindingNavigatorメンバ

BindingSourceメンバ

最初に移動

MoveFirstItem

MoveFirst

前に戻る

MovePreviousItem

MovePrevious

現在の場所

PositionItem

Current

Count

CountItem

Count

次に移動

MoveNextItem

MoveNext

最後に移動

MoveLastItem

MoveLast

新規追加

AddNewItem

AddNew

Delete

DeleteItem

RemoveCurrent

BindingNavigator コントロールフォーム追加してBindingSource などのデータ ソースバインドすると、このテーブルの関係が自動的に確立されます。

BindingNavigatorすべてのコンストラクタは、AddStandardItems メソッド呼び出してUI コントロール標準的なセット移動ツール バー関連付けます。このツール バーカスタマイズするには、次の方法うちいずれかを使用します

使用例使用例

次のコード例は、BindingNavigator コントロール使用してデータベース クエリ結果間を移動する方法示してます。結果セットDataSet格納されており、このデータ セットTextBox コントロールおよび BindingSource コンポーネントバインドされています。

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Data.SqlClient
Imports System.Windows.Forms

' This form demonstrates using a BindingNavigator to display 
' rows from a database query sequentially.
Public Class Form1
    Inherits Form

    ' This is the BindingNavigator that allows the user
    ' to navigate through the rows in a DataSet.
    Private customersBindingNavigator As New
 BindingNavigator()

    ' This is the BindingSource that provides data for
    ' the Textbox control.
    Private customersBindingSource As New
 BindingSource()

    ' This is the TextBox control that displays the CompanyName
    ' field from the the DataSet.
    Private companyNameTextBox As New
 TextBox()

    Public Sub New()
        ' Set up the BindingSource component.
        Me.customersBindingNavigator.BindingSource = Me.customersBindingSource
        Me.customersBindingNavigator.Dock = DockStyle.Top
        Me.Controls.Add(Me.customersBindingNavigator)

        ' Set up the TextBox control for displaying company names.
        Me.companyNameTextBox.Dock = DockStyle.Bottom
        Me.Controls.Add(Me.companyNameTextBox)

        ' Set up the form.
        Me.Size = New Size(800, 200)
        AddHandler Me.Load, AddressOf
 Form1_Load
    End Sub

    Private Sub Form1_Load(ByVal
 sender As Object, ByVal
 e As EventArgs)

        ' Open a connection to the database.
        ' Replace the value of connectString with a valid 
        ' connection string to a Northwind database accessible 
        ' to your system.
        Dim connectString As String
 = _
        "Integrated Security=SSPI;Persist Security Info=False;"
 + _
        "Initial Catalog=Northwind;Data Source=localhost"

        Dim connection As New
 SqlConnection()
        connection.ConnectionString = connectString
        connection.Open()

        ' Execute the query.
        Dim command As New
 SqlCommand( _
        "Select * From Customers", connection)

        Dim reader As SqlDataReader = _
        command.ExecuteReader(CommandBehavior.CloseConnection)

        ' Load the Customers result set into the DataSet.
        Dim ds As New DataSet("Northwind
 Customers")
        ds.Load( _
        reader, _
        LoadOption.OverwriteChanges, _
        New String() {"Customers"})

        ' Assign the DataSet as the DataSource for the BindingSource.
        Me.customersBindingSource.DataSource = ds

        ' Bind the CompanyName field to the TextBox control.
        Me.companyNameTextBox.DataBindings.Add( _
        New Binding( _
        "Text", _
        Me.customersBindingSource, _
        "CompanyName", _
        True))
    End Sub

End Class
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Data.SqlClient;
using System.Windows.Forms;

// This form demonstrates using a BindingNavigator to display 
// rows from a database query sequentially.
public class Form1 : Form
{
    // This is the BindingNavigator that allows the user
    // to navigate through the rows in a DataSet.
    BindingNavigator customersBindingNavigator = new BindingNavigator();

    // This is the BindingSource that provides data for
    // the Textbox control.
    BindingSource customersBindingSource = new BindingSource();

    // This is the TextBox control that displays the CompanyName
    // field from the the DataSet.
    TextBox companyNameTextBox = new TextBox();

    public Form1()
    {
        // Set up the BindingSource component.
        this.customersBindingNavigator.BindingSource = this.customersBindingSource;
        this.customersBindingNavigator.Dock = DockStyle.Top;
        this.Controls.Add(this.customersBindingNavigator);

        // Set up the TextBox control for displaying company names.
        this.companyNameTextBox.Dock = DockStyle.Bottom;
        this.Controls.Add(this.companyNameTextBox);

        // Set up the form.
        this.Size = new Size(800, 200);
        this.Load += new EventHandler(Form1_Load);
    }

    void Form1_Load(object sender, EventArgs e)
    {   
        // Open a connection to the database.
        // Replace the value of connectString with a valid 
        // connection string to a Northwind database accessible 
        // to your system.
        string connectString = 
            "Integrated Security=SSPI;Persist Security Info=False;" +
            "Initial Catalog=Northwind;Data Source=localhost";
        SqlConnection connection = new SqlConnection();
        connection.ConnectionString = connectString;
        connection.Open();

        // Execute the query.
        SqlCommand command = new SqlCommand(
            "Select * From Customers", connection);
        SqlDataReader reader = command.ExecuteReader(
            CommandBehavior.CloseConnection);

        // Load the Customers result set into the DataSet.
        DataSet ds = new DataSet("Northwind Customers");
        ds.Load(
            reader, 
            LoadOption.OverwriteChanges, 
            new string[] { "Customers"
 });

        // Assign the DataSet as the DataSource for the BindingSource.
        this.customersBindingSource.DataSource = ds;

        // Bind the CompanyName field to the TextBox control.
        this.companyNameTextBox.DataBindings.Add(
            new Binding("Text", 
            this.customersBindingSource, 
            "CompanyName", 
            true));
    }
}
#using <System.dll>
#using <System.Data.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
#using <System.EnterpriseServices.dll>
#using <System.Transactions.dll>
#using <System.Xml.dll>

using namespace System;
using namespace System::Collections::Generic;
using namespace System::ComponentModel;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Data::SqlClient;
using namespace System::Windows::Forms;

// This form demonstrates using a BindingNavigator to display
// rows from a database query sequentially.
public ref class Form1 : public
 Form
{
    // This is the BindingNavigator that allows the user
    // to navigate through the rows in a DataSet.
    BindingNavigator^ customersBindingNavigator;

    // This is the BindingSource that provides data for
    // the Textbox control.
    BindingSource^ customersBindingSource;

    // This is the TextBox control that displays the CompanyName
    // field from the the DataSet.
    TextBox^ companyNameTextBox;

public:
    Form1()
    {
        // Set up the BindingSource component.
        this->customersBindingSource = gcnew BindingSource();
        this->companyNameTextBox = gcnew TextBox();
        this->customersBindingNavigator = gcnew BindingNavigator();
        this->customersBindingNavigator->BindingSource =
            this->customersBindingSource;
        this->customersBindingNavigator->Dock = DockStyle::Top;
        this->Controls->Add(this->customersBindingNavigator);

        // Set up the TextBox control for displaying company names.
        this->companyNameTextBox->Dock = DockStyle::Bottom;
        this->Controls->Add(this->companyNameTextBox);

        // Set up the form.
        this->Size = System::Drawing::Size(800, 200);
        this->Load += gcnew EventHandler(this,
 &Form1::Form1_Load);
    }

private:
    void Form1_Load(Object^ sender, EventArgs^ e)
    {
        // Open a connection to the database.
        // Replace the value of connectString with a valid
        // connection string to a Northwind database accessible
        // to your system.
        String^ connectString =
            "Integrated Security=SSPI;Persist Security Info=False;" +
            "Initial Catalog=Northwind;Data Source=localhost";
        SqlConnection^ connection = gcnew SqlConnection();
        connection->ConnectionString = connectString;
        connection->Open();

        // Execute the query.
        SqlCommand^ command = gcnew SqlCommand(
            "Select * From Customers", connection);
        SqlDataReader^ reader = command->ExecuteReader(
            CommandBehavior::CloseConnection);

        // Load the Customers result set into the DataSet.
        DataSet^ ds = gcnew DataSet("Northwind Customers");
        ds->Load(reader, LoadOption::OverwriteChanges,
            gcnew array<String^> {"Customers"});

        // Assign the DataSet as the DataSource for the
        // BindingSource.
        this->customersBindingSource->DataSource = ds->Tables[0];

        // Bind the CompanyName field to the TextBox control.
        this->companyNameTextBox->DataBindings->Add(gcnew
 Binding("Text",
            this->customersBindingSource, "CompanyName",
 true));
    }
};
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
         System.Windows.Forms.ScrollableControl
           System.Windows.Forms.ToolStrip
            System.Windows.Forms.BindingNavigator
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「BindingNavigator クラス」の関連用語

BindingNavigator クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



BindingNavigator クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS