Uredi

Deli z drugimi prek


GridColumnStylesCollection.Contains Method

Definition

Gets a value indicating whether the GridColumnStylesCollection contains a specific DataGridColumnStyle.

Overloads

Contains(String)

Gets a value indicating whether the GridColumnStylesCollection contains the DataGridColumnStyle with the specified name.

Contains(DataGridColumnStyle)

Gets a value indicating whether the GridColumnStylesCollection contains the specified DataGridColumnStyle.

Contains(PropertyDescriptor)

Gets a value indicating whether the GridColumnStylesCollection contains a DataGridColumnStyle associated with the specified PropertyDescriptor.

Contains(String)

Gets a value indicating whether the GridColumnStylesCollection contains the DataGridColumnStyle with the specified name.

public:
 bool Contains(System::String ^ name);
public bool Contains (string name);
member this.Contains : string -> bool
Public Function Contains (name As String) As Boolean

Parameters

name
String

The MappingName of the desired DataGridColumnStyle.

Returns

true if the collection contains the DataGridColumnStyle; otherwise, false.

Examples

The following code example uses the Contains method to determine if a DataGridColumnStyle with a given MappingName exists in the GridColumnStylesCollection.

Private Sub ContainsThisDataCol()
    ' Use the Contains method to determine whether a specific
    ' DataGridColumnStyle with the same MappingName exists.
    Console.WriteLine(DataGrid1.TableStyles(0). _
    GridColumnStyles.Contains("FirstName"))
End Sub

Remarks

The caption of a DataGridColumnStyle is set with the HeaderText property.

Use the Contains method to determine if a particular DataGridColumnStyle exists before invoking the Remove method to remove the item. If you need to know the index of a particular DataGridColumnStyle, use the IndexOf method.

See also

Applies to

Contains(DataGridColumnStyle)

Gets a value indicating whether the GridColumnStylesCollection contains the specified DataGridColumnStyle.

public:
 bool Contains(System::Windows::Forms::DataGridColumnStyle ^ column);
public bool Contains (System.Windows.Forms.DataGridColumnStyle column);
member this.Contains : System.Windows.Forms.DataGridColumnStyle -> bool
Public Function Contains (column As DataGridColumnStyle) As Boolean

Parameters

Returns

true if the collection contains the DataGridColumnStyle; otherwise, false.

Examples

The following code example uses the Contains method to determine if a GridColumnStylesCollection contains a specific DataGridColumnStyle.

Private Sub ContainsThisDataCol()
   Dim myGridColumnCol As GridColumnStylesCollection
   myGridColumnCol = dataGrid1.TableStyles(0).GridColumnStyles
   ' Get the CurrencyManager for the table you want to add a column to.
   Dim myCurrencyManager As CurrencyManager = _
   CType(Me.BindingContext(ds.Tables("Suppliers")), CurrencyManager)
   ' Get the PropertyDescriptor for the DataColumn of the new column.
   Dim pd As PropertyDescriptor = _
   myCurrencyManager.GetItemProperties()("City")
   Dim myColumn As New DataGridTextBoxColumn()
   myColumn.PropertyDescriptor = pd
   ' Test to see if the present columns contains the new object.
   Console.WriteLine(DataGrid1.TableStyles(0).GridColumnStyles. _
   Contains(myColumn))
End Sub

Remarks

Use the Contains method to determine if a particular DataGridColumnStyle exists before invoking the Remove method to remove the item. If you need to know the index of a particular DataGridColumnStyle, use the IndexOf method.

See also

Applies to

Contains(PropertyDescriptor)

Gets a value indicating whether the GridColumnStylesCollection contains a DataGridColumnStyle associated with the specified PropertyDescriptor.

public:
 bool Contains(System::ComponentModel::PropertyDescriptor ^ propDesc);
public:
 bool Contains(System::ComponentModel::PropertyDescriptor ^ propertyDescriptor);
public bool Contains (System.ComponentModel.PropertyDescriptor propDesc);
public bool Contains (System.ComponentModel.PropertyDescriptor propertyDescriptor);
member this.Contains : System.ComponentModel.PropertyDescriptor -> bool
member this.Contains : System.ComponentModel.PropertyDescriptor -> bool
Public Function Contains (propDesc As PropertyDescriptor) As Boolean
Public Function Contains (propertyDescriptor As PropertyDescriptor) As Boolean

Parameters

propDescpropertyDescriptor
PropertyDescriptor

The PropertyDescriptor associated with the desired DataGridColumnStyle.

Returns

true if the collection contains the DataGridColumnStyle; otherwise, false.

Examples

The following code example uses the Contains method to determine if a GridColumnStylesCollection contains a DataGridColumnStyle associated with a specified PropertyDescriptor.

Private Sub ContainsThisDataCol()
   Dim myPropertyDescriptor As PropertyDescriptor
   Dim myPropertyDescriptorCollection As PropertyDescriptorCOllection
   myPropertyDescriptorCollection = _
   me.BindingContext(DataSet1, "Customers").GetItemProperties()
   myPropertyDescriptor = myPropertyDescriptorCollection("FirstName")

   Dim trueOrFalse As Boolean
   ' Set the variable to a known column in the grid's DataTable.
   trueOrFalse = DataGrid1.TableStyles(0).GridColumnStyles. _
   Contains(myPropertyDescriptor)
   Console.WriteLine(trueOrFalse)
End Sub

Remarks

To get a PropertyDescriptorCollection, use the GetItemProperties method of the BindingManagerBase class. Pass the MappingName of the DataGridColumnStyle to the Item[] property of the PropertyDescriptorCollection to return the PropertyDescriptor for a specific column.

Use the Contains method to determine if a particular DataGridColumnStyle exists before invoking the Remove method to remove the item. If you need to know the index of a particular DataGridColumnStyle, use the IndexOf method.

See also

Applies to