指定した配列内の属性がコレクション内の属性と同じかどうかを判断します。
Overloads Public Function Matches( _
ByVal attributes() As Attribute _) As Boolean
[C#]
public bool Matches(Attribute[] attributes);
[C++]
public: bool Matches(Attribute* attributes[]);
[JScript]
public function Matches(
attributes : Attribute[]) : Boolean;
パラメータ
- attributes
コレクション内の属性と比較する対象の MemberAttributes の配列。
戻り値
配列内の属性がコレクションに格納されていて、その値がコレクション内の属性の値と同じ場合は true 。それ以外の場合は false 。
解説
属性が一致するかどうかを確認する機能がサポートされています。
使用例
ボタンの属性とテキスト ボックスの属性を比較して、それらが一致しているかどうかを調べる例を次に示します。この例は、フォーム上に button1
と textBox1
が作成されていることを前提としています。
Private Sub MatchesAttributes()
' Creates a new collection and assigns it the attributes for button1.
Dim myCollection As AttributeCollection
myCollection = TypeDescriptor.GetAttributes(button1)
' Checks to see whether the attributes in myCollection match the attributes.
' for textBox1.
Dim myAttrArray(100) As Attribute
TypeDescriptor.GetAttributes(textBox1).CopyTo(myAttrArray, 0)
If myCollection.Matches(myAttrArray) Then
textBox1.Text = "The attributes in the button and text box match."
Else
textBox1.Text = "The attributes in the button and text box do not match."
End If
End Sub
[C#]
private void MatchesAttributes() {
// Creates a new collection and assigns it the attributes for button1.
AttributeCollection myCollection;
myCollection = TypeDescriptor.GetAttributes(button1);
// Checks to see whether the attributes in myCollection match the attributes for textBox1.
Attribute[] myAttrArray = new Attribute[100];
TypeDescriptor.GetAttributes(textBox1).CopyTo(myAttrArray, 0);
if (myCollection.Matches(myAttrArray))
textBox1.Text = "The attributes in the button and text box match.";
else
textBox1.Text = "The attributes in the button and text box do not match.";
}
[C++]
private:
void MatchesAttributes()
{
// Creates a new collection and assigns it the attributes for button1.
AttributeCollection* myCollection;
myCollection = TypeDescriptor::GetAttributes( button1 );
// Checks to see whether the attributes in myCollection match the attributes for textBox1.
Attribute* myAttrArray[] = new Attribute*[100];
TypeDescriptor::GetAttributes( textBox1 )->CopyTo(myAttrArray, 0);
if ( myCollection->Matches( myAttrArray ))
textBox1->Text = S"The attributes in the button and text box match.";
else
textBox1->Text = S"The attributes in the button and text box do not match.";
}
[JScript]
private function MatchesAttribute() {
// Creates a new collection and assigns it the attributes for button1.
var myCollection : AttributeCollection;
myCollection = TypeDescriptor.GetAttributes(button1);
// Checks to see whether the attributes in myCollection match the attributes for textBox1.
var myAttrArray : Attribute[] = new Attribute[100];
TypeDescriptor.GetAttributes(textBox1).CopyTo(myAttrArray, 0);
if (myCollection.Matches(myAttrArray))
textBox1.Text = "The attributes in the button and text box match.";
else
textBox1.Text = "The attributes in the button and text box do not match.";
Console.WriteLine(textBox1.Text);
}
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
AttributeCollection クラス | AttributeCollection メンバ | System.ComponentModel 名前空間 | AttributeCollection.Matches オーバーロードの一覧 | Attribute