ColumnDefinitionCollection.Contains(ColumnDefinition) 方法

定义

确定 ColumnDefinition 中是否存在给定的 ColumnDefinitionCollection

public:
 virtual bool Contains(System::Windows::Controls::ColumnDefinition ^ value);
public bool Contains (System.Windows.Controls.ColumnDefinition value);
abstract member Contains : System.Windows.Controls.ColumnDefinition -> bool
override this.Contains : System.Windows.Controls.ColumnDefinition -> bool
Public Function Contains (value As ColumnDefinition) As Boolean

参数

value
ColumnDefinition

标识要测试的 ColumnDefinition

返回

Boolean

如果集合中存在 ColumnDefinition,则为 true;否则为 false

实现

示例

下面的示例演示如何使用 Contains 该方法来确定 ColumnDefinition 是否存在于其中 ColumnDefinitionCollection

private void containsCol(object sender, RoutedEventArgs e)
{
    if (grid1.ColumnDefinitions.Contains(colDef1))
    {
        tp3.Text = "Grid Contains ColumnDefinition colDef1";
    }
    else
    {
        tp3.Text = "Grid Does Not Contain ColumnDefinition colDef1";
    }
}
Private Sub containsCol(ByVal sender As Object, ByVal e As RoutedEventArgs)
    If (grid1.ColumnDefinitions.Contains(colDef1)) Then
        tp3.Text = "Grid Contains ColumnDefinition colDef1"
    Else
        tp3.Text = "Grid Does Not Contain ColumnDefinition colDef1"
    End If
End Sub

若要查看完整的示例,请参阅 如何:使用 ColumnDefinitionsCollections 和 RowDefinitionsCollections 操作列和行

适用于

另请参阅