GridColumnStylesCollection.Contains Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar ett värde som anger om innehåller GridColumnStylesCollection en specifik DataGridColumnStyle.
Överlagringar
| Name | Description |
|---|---|
| Contains(String) |
Hämtar ett värde som anger om GridColumnStylesCollection innehåller DataGridColumnStyle med det angivna namnet. |
| Contains(DataGridColumnStyle) |
Hämtar ett värde som anger om GridColumnStylesCollection innehåller den angivna DataGridColumnStyle. |
| Contains(PropertyDescriptor) |
Hämtar ett värde som anger om GridColumnStylesCollection innehåller en DataGridColumnStyle associerad med den angivna PropertyDescriptor. |
Contains(String)
Hämtar ett värde som anger om GridColumnStylesCollection innehåller DataGridColumnStyle med det angivna namnet.
public:
bool Contains(System::String ^ name);
public bool Contains(string name);
member this.Contains : string -> bool
Public Function Contains (name As String) As Boolean
Parametrar
- name
- String
Den MappingName önskade DataGridColumnStyle.
Returer
true om samlingen innehåller DataGridColumnStyle, annars , false.
Exempel
I följande kodexempel används Contains metoden för att avgöra om en DataGridColumnStyle med en viss MappingName finns i 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
Kommentarer
Undertexten för en DataGridColumnStyle anges med HeaderText egenskapen .
Contains Använd metoden för att avgöra om det finns en viss uppgift DataGridColumnStyle innan du anropar Remove metoden för att ta bort objektet. Om du behöver känna till indexet för en viss DataGridColumnStyleanvänder du IndexOf metoden .
Se även
Gäller för
Contains(DataGridColumnStyle)
Hämtar ett värde som anger om GridColumnStylesCollection innehåller den angivna 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
Parametrar
- column
- DataGridColumnStyle
DataGridColumnStyleÖnskad .
Returer
true om samlingen innehåller DataGridColumnStyle, annars , false.
Exempel
I följande kodexempel används Contains metoden för att avgöra om en GridColumnStylesCollection innehåller en specifik 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
Kommentarer
Contains Använd metoden för att avgöra om det finns en viss uppgift DataGridColumnStyle innan du anropar Remove metoden för att ta bort objektet. Om du behöver känna till indexet för en viss DataGridColumnStyleanvänder du IndexOf metoden .
Se även
Gäller för
Contains(PropertyDescriptor)
Hämtar ett värde som anger om GridColumnStylesCollection innehåller en DataGridColumnStyle associerad med den angivna 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
Parametrar
- propDescpropertyDescriptor
- PropertyDescriptor
Associerad PropertyDescriptor med önskad DataGridColumnStyle.
Returer
true om samlingen innehåller DataGridColumnStyle, annars , false.
Exempel
I följande kodexempel används Contains metoden för att avgöra om en GridColumnStylesCollection innehåller en DataGridColumnStyle associerad med en angiven 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
Kommentarer
Om du vill hämta en PropertyDescriptorCollectionanvänder du GetItemProperties -metoden för BindingManagerBase klassen. MappingName DataGridColumnStyle Skicka egenskapen för till Item[] egenskapen PropertyDescriptorCollection för för att returnera PropertyDescriptor för en specifik kolumn.
Contains Använd metoden för att avgöra om det finns en viss uppgift DataGridColumnStyle innan du anropar Remove metoden för att ta bort objektet. Om du behöver känna till indexet för en viss DataGridColumnStyleanvänder du IndexOf metoden .