Export (0) Print
Expand All

DataGridColumnStyle.MappingName Property

Gets or sets the name used to map the column style to a data member.

[Visual Basic]
Public Property MappingName As String
[C#]
public string MappingName {get; set;}
[C++]
public: __property String* get_MappingName();
public: __property void set_MappingName(String*);
[JScript]
public function get MappingName() : String;
public function set MappingName(String);

Property Value

The name used to map the column style to a data member.

Remarks

The MappingName property is usually set to the ColumnName of a DataColumn. Whenever the DataTable containing the DataColumn is displayed, the DataGridColumnStyle with the same MappingName will be used to display the data.

The comparison used to match the MappingName to the ColumnName is case-insensitive.

Example

[Visual Basic, C#, C++] The following example creates a DataGridTableStyle object, and adds two DataGridColumnStyle objects to the GridColumnStylesCollection. The MappingName for each DataGridColumnStyle object is set to the ColumnName of a DataColumn.

[Visual Basic] 
Private Sub AddDataGridTableStyle()
   ' Create a new DataGridTableStyle and set MappingName.
   Dim myGridStyle As DataGridTableStyle = _
   new DataGridTableStyle()
   myGridStyle.MappingName = "Customers"

   ' Add two DataGridColumnStyle objects.
   Dim colStyle1 As DataGridColumnStyle = _
   new DataGridTextBoxColumn()
   colStyle1.MappingName = "firstName"
   
   Dim colStyle2 As DataGridColumnStyle = _
   new DataGridBoolColumn()
   colStyle2.MappingName = "Current"

   ' Add column styles to table style.
   myGridStyle.GridColumnStyles.Add(colStyle1)
   myGridStyle.GridColumnStyles.Add(colStyle2)   

   ' Add the grid style to the GridStylesCollection.
   myDataGrid.TableStyles.Add(myGridStyle)
End Sub

[C#] 
private void AddDataGridTableStyle()
{
   // Create a new DataGridTableStyle and set MappingName.
   DataGridTableStyle myGridStyle = 
   new DataGridTableStyle();
   myGridStyle.MappingName = "Customers";

   // Create two DataGridColumnStyle objects.
   DataGridColumnStyle colStyle1 =
   new DataGridTextBoxColumn();
   colStyle1.MappingName = "firstName";
   
   DataGridColumnStyle colStyle2 =
   new DataGridBoolColumn();
   colStyle2.MappingName = "Current";

   // Add column styles to table style.
   myGridStyle.GridColumnStyles.Add(colStyle1);
   myGridStyle.GridColumnStyles.Add(colStyle2);   

   // Add the grid style to the GridStylesCollection.
   myDataGrid.TableStyles.Add(myGridStyle);
}

[C++] 
private:
    void AddDataGridTableStyle() {
        // Create a new DataGridTableStyle and set MappingName.
        DataGridTableStyle* myGridStyle = new DataGridTableStyle();
        myGridStyle->MappingName = S"Customers";

        // Create two DataGridColumnStyle objects.
        DataGridColumnStyle* colStyle1 = new DataGridTextBoxColumn();
        colStyle1->MappingName = S"firstName";

        DataGridColumnStyle* colStyle2 = new DataGridBoolColumn();
        colStyle2->MappingName = S"Current";

        // Add column styles to table style.
        myGridStyle->GridColumnStyles->Add(colStyle1);
        myGridStyle->GridColumnStyles->Add(colStyle2);

        // Add the grid style to the GridStylesCollection.
        myDataGrid->TableStyles->Add(myGridStyle);
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataGridColumnStyle Class | DataGridColumnStyle Members | System.Windows.Forms Namespace

Show:
© 2014 Microsoft