DataGridColumnStyle.MappingName 属性

定义

获取或设置列样式所映射到的数据成员的名称。Gets or sets the name of the data member to map the column style to.

public:
 property System::String ^ MappingName { System::String ^ get(); void set(System::String ^ value); };
public string MappingName { get; set; }
member this.MappingName : string with get, set
Public Property MappingName As String

属性值

列样式所映射到的数据成员的名称。The name of the data member to map the column style to.

示例

下面的代码示例创建一个DataGridTableStyle,并将两DataGridColumnStyle个对象添加GridColumnStylesCollection到中。The following code example creates a DataGridTableStyle, and adds two DataGridColumnStyle objects to the GridColumnStylesCollection. 每个DataGridColumnStyle的都ColumnName 设置DataColumn为的。 MappingNameThe MappingName for each DataGridColumnStyle is set to the ColumnName of a DataColumn.

void AddDataGridTableStyle()
{
   // Create a new DataGridTableStyle and set MappingName.
   DataGridTableStyle^ myGridStyle = gcnew DataGridTableStyle;
   myGridStyle->MappingName = "Customers";
   
   // Create two DataGridColumnStyle objects.
   DataGridColumnStyle^ colStyle1 = gcnew DataGridTextBoxColumn;
   colStyle1->MappingName = "firstName";
   DataGridColumnStyle^ colStyle2 = gcnew 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 );
}
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);
}
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

注解

用于与数据成员匹配的MappingName比较不区分大小写。The comparison used to match the MappingName to the data member is case-insensitive.

DataGridColumnStyle数据源与包含此列样式的的MappingName属性所指示的数据源匹配时,此属性DataGridTableStyle用于呈现所指示的数据成员的数据。This DataGridColumnStyle is used to render the data in the indicated data member whenever the data source matches the one indicated by the MappingName property of the DataGridTableStyle that contains this column style.

属性通常设置ColumnName为的DataColumnDataGridColumnStyle.MappingNameThe DataGridColumnStyle.MappingName property is usually set to the ColumnName of a DataColumn.

适用于