DataGridTableStyle.MappingName プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGridTableStyle.MappingName プロパティの意味・解説 

DataGridTableStyle.MappingName プロパティ

テーブル特定のデータ ソース割り当てるときに使用する名前を取得または設定します

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

Dim instance As DataGridTableStyle
Dim value As String

value = instance.MappingName

instance.MappingName = value
public string MappingName { get;
 set; }
/** @property */
public String get_MappingName ()

/** @property */
public void set_MappingName (String value)
public function get MappingName
 () : String

public function set MappingName
 (value : String)

プロパティ
グリッド特定のデータ ソース割り当てるときに使用する名前。

解説解説

DataGrid をオブジェクト厳密に指定され配列バインドするには、オブジェクト型パブリック プロパティ含まれている必要があります配列表示する DataGridTableStyle を作成するには、DataGridTableStyle.MappingName プロパティtypename設定します。なお、この typename実際オブジェクト型名に置き換えてくださいまた、MappingName プロパティでは大文字と小文字区別されることに注意してください。型の名前は正確に指定する必要があります例については、MappingName プロパティトピック参照してください

また、DataGrid を ArrayList にバインドできますArrayList特長は、複数の型のオブジェクト格納できることです。ただし、DataGridリスト内のすべての項目の型が 1 番目の項目の型と同じ場合限りリストバインドできます。つまり、すべてのオブジェクトの型が同じであるか、リスト内の最初の項目と同じクラスからすべてのクラス継承している必要があります。たとえば、リスト内の最初の項目が Control場合2 番目の項目は (Control から継承した) TextBoxできます逆に、1 番目の項目が TextBox場合2 番目のオブジェクトControl になることはできません。さらに、ArrayList は、バインディングするときは、項目を含んでいる必要があります。空の ArrayList場合、空のグリッドとなりますArrayListバインディングするときは、DataGridTableStyleMappingName を "ArrayList" (型の名前) に設定します

既定値は、グリッドの CurrencyManager で管理されるリストの名前です。DataGridTableStyleCurrencyManager は、DataGridTableStyle コンストラクタ使用して設定されます。

MappingNameChanged イベントは、MappingName の値が変更される発生します

使用例使用例

Widget オブジェクト配列作成しSystem.Windows.Forms.DataGrid コントロールをこの配列バインドするコード例次に示します。この例では、次にDataGridTableStyle作成しクラス名角かっこ付けた文字列MappingName設定してます。

Sub BindToArray()
    ' Creates an array of Widget objects (defined below).
    Dim Widgets(2) As Widget
    Dim tempWidget As Widget

    tempWidget = New Widget()
    tempWidget.Model = "AAA"
    tempWidget.Id = "A100"
    tempWidget.Price = Convert.ToDecimal(3.8)
    Widgets(0) = tempWidget

    ' The first Widget includes an array of Part objects.
    Dim p1 As New Part()
    p1.PartId = "PartX"
    Dim p2 As New Part()
    p2.PartId = "PartY"

    ' Note that the Widgets.Parts property returns an ArrayList.
    ' Add the parts to the ArrayList using the AddRange method.
    tempWidget.Parts.AddRange(New Part() {p1, p2})

    tempWidget = New Widget()
    tempWidget.Model = "BBB"
    tempWidget.Id = "B100"
    tempWidget.Price = Convert.ToDecimal(1.52)
    Widgets(1) = tempWidget

    tempWidget = New Widget()
    tempWidget.Id = "CCC"
    tempWidget.Model = "B100"
    tempWidget.Price = Convert.ToDecimal(2.14)
    Widgets(2) = tempWidget

    DataGrid1.SetDataBinding(Widgets, "")
    CreateTableStyle()
End Sub


Private Sub CreateTableStyle()
    ' Creates two DataGridTableStyle objects, one for the Widget
    ' array, and one for the Parts ArrayList.
    Dim widgetTable As New
 DataGridTableStyle()
    ' Sets the MappingName to the class name plus brackets.    
    widgetTable.MappingName = "Widget[]"

    ' Sets the AlternatingBackColor so you can see the difference.
    widgetTable.AlternatingBackColor = System.Drawing.Color.LightBlue

    ' Creates three column styles.
    Dim modelColumn As New
 DataGridTextBoxColumn()
    modelColumn.MappingName = "Model"
    modelColumn.HeaderText = "Model"

    Dim IdColumn As New
 DataGridTextBoxColumn()
    IdColumn.MappingName = "Id"
    IdColumn.HeaderText = "Id"

    Dim priceColumn As New
 DataGridTextBoxColumn()
    priceColumn.MappingName = "Price"
    priceColumn.HeaderText = "Price"
    priceColumn.Format = "c"

    ' Adds the column styles to the grid table style.
    widgetTable.GridColumnStyles.Add(modelColumn)
    widgetTable.GridColumnStyles.Add(IdColumn)
    widgetTable.GridColumnStyles.Add(priceColumn)

    ' Add the table style to the collection, but clear the 
    ' collection first.
    DataGrid1.TableStyles.Clear()
    DataGrid1.TableStyles.Add(widgetTable)

    ' Create another table style, one for the related data.
    Dim partsTable As New
 DataGridTableStyle()
    ' Set the MappingName to an ArrayList. Note that you need not 
    ' include brackets.
    partsTable.MappingName = "ArrayList"
    Dim partIdColumn As New
 DataGridTextBoxColumn()
    partIdColumn.MappingName = "PartID"
    partIdColumn.HeaderText = "Part ID"
    partsTable.GridColumnStyles.Add(partIdColumn)

    DataGrid1.TableStyles.Add(partsTable)
End Sub


Public Class Widget
    Private myModel As String
    Private myId As String
    Private myPrice As Decimal

    ' Use an ArrayList to create a related collection.
    Private myParts As New
 ArrayList()

    Public Property Model() As
 String
        Get
            Return myModel
        End Get
        Set(ByVal Value As
 String)
            myModel = Value
        End Set
    End Property

    Public Property Id() As
 String
        Get
            Return myId
        End Get
        Set(ByVal Value As
 String)
            myId = Value
        End Set
    End Property

    Public Property Parts() As
 ArrayList
        Get
            Return myParts
        End Get
        Set(ByVal Value As
 ArrayList)
            myParts = Value
        End Set
    End Property

    Public Property Price() As
 Decimal
        Get
            Return myPrice
        End Get
        Set(ByVal Value As
 Decimal)
            myPrice = Value
        End Set
    End Property
End Class


Public Class Part
    Private myPartId As String


    Public Property PartId() As
 String
        Get
            Return myPartId
        End Get
        Set(ByVal Value As
 String)
            myPartId = Value
        End Set
    End Property
End Class
private void BindToArray()
{
    // Create an array of Machine objects (defined below).
    Machine[] Machines = new Machine[3];
    Machine tempMachine;

    tempMachine= new Machine();
    tempMachine.Model = "AAA";
    tempMachine.Id= "A100";
    tempMachine.Price= Convert.ToDecimal(3.80);
    Machines[0]=tempMachine;

    // The first Machine includes an array of Part objects.
    Part p1 = new Part();
    p1.PartId= "PartX";
    Part p2 = new Part();
    p2.PartId= "PartY";

    // Note that the Machines.Parts property returns an ArrayList.
    // Add the parts to the ArrayList using the AddRange method.
    tempMachine.Parts.AddRange (new Part[]{p1, p2});;

    tempMachine= new Machine();
    tempMachine.Model = "BBB";
    tempMachine.Id= "B100";
    tempMachine.Price= Convert.ToDecimal(1.52);
    Machines[1]=tempMachine;

    tempMachine= new Machine();
    tempMachine.Id= "CCC";
    tempMachine.Model = "B100";
    tempMachine.Price= Convert.ToDecimal(2.14);
    Machines[2]=tempMachine;
    
    dataGrid1.SetDataBinding(Machines, "");
    CreateTableStyle();
}

private void CreateTableStyle()
{
    // Creates two DataGridTableStyle objects, one for the Machine
    // array, and one for the Parts ArrayList.

    DataGridTableStyle MachineTable = new DataGridTableStyle();
    // Sets the MappingName to the class name plus brackets.    
    MachineTable.MappingName= "Machine[]";

    // Sets the AlternatingBackColor so you can see the difference.
    MachineTable.AlternatingBackColor= System.Drawing.Color.LightBlue;

    // Creates three column styles.
    DataGridTextBoxColumn modelColumn = new DataGridTextBoxColumn();
    modelColumn.MappingName= "Model";
    modelColumn.HeaderText= "Model";

    DataGridTextBoxColumn IdColumn = new DataGridTextBoxColumn();
    IdColumn.MappingName= "Id";
    IdColumn.HeaderText= "Id";

    DataGridTextBoxColumn priceColumn = new DataGridTextBoxColumn();
    priceColumn.MappingName= "Price";
    priceColumn.HeaderText= "Price";
    priceColumn.Format = "c";

    // Adds the column styles to the grid table style.
    MachineTable.GridColumnStyles.Add(modelColumn);
    MachineTable.GridColumnStyles.Add(IdColumn);
    MachineTable.GridColumnStyles.Add(priceColumn);

    // Add the table style to the collection, but clear the 
    // collection first.
    dataGrid1.TableStyles.Clear();
    dataGrid1.TableStyles.Add(MachineTable);

    // Create another table style, one for the related data.
    DataGridTableStyle partsTable = new DataGridTableStyle();
    // Set the MappingName to an ArrayList. Note that you need not 
    // include brackets.
    partsTable.MappingName= "ArrayList";
    DataGridTextBoxColumn partIdColumn = new DataGridTextBoxColumn();
    partIdColumn.MappingName= "PartID";
    partIdColumn.HeaderText = "Part ID";
    partsTable.GridColumnStyles.Add(partIdColumn);

    dataGrid1.TableStyles.Add(partsTable);

}
public class Machine
{
    private string model;
    private string id;
    private decimal price;

    // Use an ArrayList to create a related collection.
    private ArrayList parts = new ArrayList();

    public string Model
    {
        get{return model;}
        set{model=value;}
    }
    public string Id
    {
        get{return id;}
        set{id = value;}
    }
    public ArrayList Parts
    {
        get{return parts;}
        set{parts = value;}
    }

    public decimal Price
    {
        get{return price;}
        set{price = value;}
    }
}

public class Part
{
    private string partId;

    public string PartId
    {
        get{return partId;}
        set{partId = value;}
    }
}
    void BindToArray()
    {
        // Create an array of Machine objects (defined below).
        array<Machine^>^ Machines = gcnew array<Machine^>(3);
        Machine^ tempMachine;

        tempMachine = gcnew Machine();
        tempMachine->Model = "AAA";
        tempMachine->Id = "A100";
        tempMachine->Price = Convert::ToDecimal(3.80);
        Machines[0] = tempMachine;

        // The first Machine includes an array of Part objects.
        Part^ p1 = gcnew Part();
        p1->PartId = "PartX";
        Part^ p2 = gcnew Part();
        p2->PartId = "PartY";

        // Note that the Machines.Parts property returns an ArrayList.
        // Add the parts to the ArrayList using the AddRange method.
        tempMachine->Parts->AddRange(gcnew array<Part^> {p1, p2}); 

        tempMachine = gcnew Machine();
        tempMachine->Model = "BBB";
        tempMachine->Id = "B100";
        tempMachine->Price = Convert::ToDecimal(1.52);
        Machines[1] = tempMachine;

        tempMachine = gcnew Machine();
        tempMachine->Id = "CCC";
        tempMachine->Model = "B100";
        tempMachine->Price = Convert::ToDecimal(2.14);
        Machines[2] = tempMachine;

        bindedDataGrid->SetDataBinding(Machines, "");
        CreateTableStyle();
    }

    void CreateTableStyle()
    {
        // Creates two DataGridTableStyle objects, one for the Machine
        // array, and one for the Parts ArrayList.

        DataGridTableStyle^ machineTable = gcnew DataGridTableStyle();
        // Sets the MappingName to the class name plus brackets.
        machineTable->MappingName = "Machine[]";

        // Sets the AlternatingBackColor so you can see the difference.
        machineTable->AlternatingBackColor = 
            System::Drawing::Color::LightBlue;

        // Creates three column styles.
        DataGridTextBoxColumn^ modelColumn = gcnew DataGridTextBoxColumn();
        modelColumn->MappingName = "Model";
        modelColumn->HeaderText = "Model";

        DataGridTextBoxColumn^ idColumn = gcnew DataGridTextBoxColumn();
        idColumn->MappingName = "Id";
        idColumn->HeaderText = "Id";

        DataGridTextBoxColumn^ priceColumn = gcnew DataGridTextBoxColumn();
        priceColumn->MappingName = "Price";
        priceColumn->HeaderText = "Price";
        priceColumn->Format = "c";

        // Adds the column styles to the grid table style.
        machineTable->GridColumnStyles->Add(modelColumn);
        machineTable->GridColumnStyles->Add(idColumn);
        machineTable->GridColumnStyles->Add(priceColumn);

        // Add the table style to the collection, but clear the
        // collection first.
        bindedDataGrid->TableStyles->Clear();
        bindedDataGrid->TableStyles->Add(machineTable);

        // Create another table style, one for the related data.
        DataGridTableStyle^ partsTable = gcnew DataGridTableStyle();
        // Set the MappingName to an ArrayList. Note that you need not
        // include brackets.
        partsTable->MappingName = "ArrayList";
        DataGridTextBoxColumn^ partIdColumn = 
            gcnew DataGridTextBoxColumn();
        partIdColumn->MappingName = "PartID";
        partIdColumn->HeaderText = "Part ID";
        partsTable->GridColumnStyles->Add(partIdColumn);
        bindedDataGrid->TableStyles->Add(partsTable);
    }

private:
    ref class Machine
    {
    private:
        String^ machineModel;
        String^ machineID;
        Decimal machinePrice;

        // Use an ArrayList to create a related collection.
        ArrayList^ machineParts;

    public:
        Machine()
        {
            machineParts = gcnew ArrayList; 
        }   

        property String^ Model
        {
            String^ get()
            {
                return machineModel;
            }
            void set(String^ value)
            {
                machineModel = value;
            }
        }

        property String^ Id
        {
            String^ get()
            {
                return machineID;
            }
            void set(String^ value)
            {
                machineID = value;
            }
        }

        property ArrayList^ Parts
        {
            ArrayList^ get()
            {
                return machineParts;
            }
            void set(ArrayList^ value)
            {
                machineParts = value;
            }
        }

        property Decimal Price
        {
            Decimal get()
            {
                return machinePrice;
            }
            void set(Decimal value)
            {
                machinePrice = value;
            }
        }
    };

private:
    ref class Part
    {
    private:
        String^ partId;

    public:
        property String^ PartId
        {
            String^ get()
            {
                return partId;
            }
            void set(String^ value)
            {
                partId = value;
            }
        }
    };
private void BindToArray()
{
    // Create an array of Machine objects (defined below).
    Machine machines[] = new Machine[3];
    Machine tempMachine;

    tempMachine = new Machine();
    tempMachine.set_Model("AAA");
    tempMachine.set_Id("A100");
    tempMachine.set_Price(Convert.ToDecimal(3.8));
    machines.set_Item(0, tempMachine);

    // The first Machine includes an array of Part objects.
    Part p1 = new Part();
    p1.set_PartId("PartX");

    Part p2 = new Part();
    p2.set_PartId("PartY");

    // Note that the machines.Parts property returns an ArrayList.
    // Add the parts to the ArrayList using the AddRange method.
    tempMachine.get_Parts().AddRange(new Part[] { p1, p2 });
    tempMachine = new Machine();
    tempMachine.set_Model("BBB");
    tempMachine.set_Id("B100");
    tempMachine.set_Price(Convert.ToDecimal(1.52));
    machines.set_Item(1, tempMachine);
    tempMachine = new Machine();
    tempMachine.set_Id("CCC");
    tempMachine.set_Model("B100");
    tempMachine.set_Price(Convert.ToDecimal(2.14));
    machines.set_Item(2, tempMachine);
    dataGrid1.SetDataBinding(machines, "");
    CreateTableStyle();
} //BindToArray

private void CreateTableStyle()
{
    // Creates two DataGridTableStyle objects, one for the Machine
    // array, and one for the Parts ArrayList.
    DataGridTableStyle MachineTable = new DataGridTableStyle();

    // Sets the MappingName to the class name plus brackets.    
    MachineTable.set_MappingName("Machine[]");

    // Sets the AlternatingBackColor so you can see the difference.
    MachineTable.set_AlternatingBackColor(System.Drawing.Color.
        get_LightBlue());

    // Creates three column styles.
    DataGridTextBoxColumn modelColumn = new DataGridTextBoxColumn();

    modelColumn.set_MappingName("Model");
    modelColumn.set_HeaderText("Model");

    DataGridTextBoxColumn IdColumn = new DataGridTextBoxColumn();

    IdColumn.set_MappingName("Id");
    IdColumn.set_HeaderText("Id");

    DataGridTextBoxColumn priceColumn = new DataGridTextBoxColumn();

    priceColumn.set_MappingName("Price");
    priceColumn.set_HeaderText("Price");
    priceColumn.set_Format("c");

    // Adds the column styles to the grid table style.
    MachineTable.get_GridColumnStyles().Add(modelColumn);
    MachineTable.get_GridColumnStyles().Add(IdColumn);
    MachineTable.get_GridColumnStyles().Add(priceColumn);

    // Add the table style to the collection, but clear the 
    // collection first.
    dataGrid1.get_TableStyles().Clear();
    dataGrid1.get_TableStyles().Add(MachineTable);

    // Create another table style, one for the related data.
    DataGridTableStyle partsTable = new DataGridTableStyle();

    // Set the MappingName to an ArrayList. Note that you need not 
    // include brackets.
    partsTable.set_MappingName("ArrayList");

    DataGridTextBoxColumn partIdColumn = new DataGridTextBoxColumn();

    partIdColumn.set_MappingName("PartID");
    partIdColumn.set_HeaderText("Part ID");
    partsTable.get_GridColumnStyles().Add(partIdColumn);
    dataGrid1.get_TableStyles().Add(partsTable);
} //CreateTableStyle

public class Machine
{
    private String model;
    private String id;
    private System.Decimal price;

    // Use an ArrayList to create a related collection.
    private ArrayList parts = new ArrayList();

    /** @property 
     */
    public String get_Model()
    {
        return model;
    } //get_Model

    /** @property 
     */
    public void set_Model(String value)
    {
        model = value;
    } //set_Model

    /** @property 
     */
    public String get_Id()
    {
        return id;
    } //get_Id

    /** @property 
     */
    public void set_Id(String value)
    {
        id = value;
    } //set_Id

    /** @property 
     */
    public ArrayList get_Parts()
    {
        return parts;
    } //get_Parts

    /** @property 
     */
    public void set_Parts(ArrayList value)
    {
        parts = value;
    } //set_Parts

    /** @property 
     */
    public System.Decimal get_Price()
    {
        return price;
    } //get_Price

    /** @property 
     */
    public void set_Price(System.Decimal value)
    {
        price = value;
    } //set_Price
} //Machine

public class Part
{
    private String partId;

    /** @property 
     */
    public String get_PartId()
    {
        return partId;
    } //get_PartId

    /** @property 
     */
    public void set_PartId(String value)
    {
        partId = value;
    } //set_PartId
} //Part
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridTableStyle クラス
DataGridTableStyle メンバ
System.Windows.Forms 名前空間
CurrencyManager クラス
DataGrid クラス
DataGridColumnStyle クラス
DataGrid.TableStyles プロパティ


このページでは「.NET Framework クラス ライブラリ リファレンス」からDataGridTableStyle.MappingName プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDataGridTableStyle.MappingName プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDataGridTableStyle.MappingName プロパティ を検索

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

辞書ショートカット

すべての辞書の索引

「DataGridTableStyle.MappingName プロパティ」の関連用語

DataGridTableStyle.MappingName プロパティのお隣キーワード
検索ランキング

   

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



DataGridTableStyle.MappingName プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS