次の方法で共有


ControlCollection.IsReadOnly プロパティ

ControlCollection オブジェクトが読み取り専用かどうかを示す値を取得します。

Public ReadOnly Property IsReadOnly As Boolean
[C#]
public bool IsReadOnly {get;}
[C++]
public: __property bool get_IsReadOnly();
[JScript]
public function get IsReadOnly() : Boolean;

プロパティ値

コントロールが読み取り専用の場合は true 。それ以外の場合は false 。既定値は false です。

使用例

[Visual Basic] Button コントロール (myButton) の ControlCollection の列挙子を作成するメソッドの作成例を次に示します。列挙子が作成されると、操作がスレッド セーフかどうかを確認するために IsSynchronized プロパティがチェックされます。スレッド セーフでない場合は、 SyncRoot プロパティを使用して、操作をスレッド セーフにするためのオブジェクトが取得されます。列挙処理が完了すると、 IsReadOnly プロパティの値が、ページの Label コントロールの Text プロパティの値として書き込まれます。

 
' Create a method that enuberates through a 
' button's ControlCollection in a thread-safe manner.  
Public Sub ListControlCollection(sender As Object, e As EventArgs)
   Dim myEnumerator As IEnumerator = myButton.Controls.GetEnumerator()

   ' Check the IsSynchronized property. If False,
   ' use the SyncRoot method to get an object that 
   ' allows the enumeration of all controls to be 
   ' thread safe.
   If myButton.Controls.IsSynchronized = False Then
     SyncLock myButton.Controls.SyncRoot
       While (myEnumerator.MoveNext())

       Dim myObject As Object  = myEnumerator.Current
           
         Dim childControl As LiteralControl = CType(myEnumerator.Current, LiteralControl)
         Response.Write("<b><br> This is the  text of the child Control  </b>: " & _
                        childControl.Text)
       End While
      msgReadOnly.Text = myButton.Controls.IsReadOnly.ToString()
      
      End SyncLock
   End If       
 End Sub

[C#, C++, JScript] C#、C++、および JScript のサンプルはありません。Visual Basic のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ

参照

ControlCollection クラス | ControlCollection メンバ | System.Web.UI 名前空間 | Controls