Sunday, February 21, 2010

Remove a Control Dynamically at runtime in C#

The following code could be used to remove a control dynamically at runtime:

        For i As Integer = 0 To Me.Controls.Count - 1

            If Me.Controls(i).Name = "NameofcontroltobeRemoved" Then

                Me.Controls.RemoveAt(i)

            End If

        Next i

Enjoy it.

No comments:

Post a Comment