Copying object properties

  • Thread starter Thread starter Tony Vitonis
  • Start date Start date
T

Tony Vitonis

Hi. I've created a "numeric text box" that inherits from the TextBox
control. I've given it a Replace method that looks like this:

Public Sub Replace(ByVal TB As TextBox)

Me.Size = TB.Size
Me.Location = TB.Location

TB.Parent.Controls.Add(Me)
TB.Parent.Controls.Remove(TB)

End Sub

Callers can say NumericTextBox.Replace(NormalTextBox), which works
fine.

The thing is, instead of copying just the Size and Location properties
explicitly, what I'd like to do is iterate through the TB object's
properties and copy each of them from TB to Me. Is there a way to do
this? Thanks.
 
Hi,
You will need to use Reflection and use the Propertyinfo class to get the
different proerties of a textbox and then get to its values.


Anand Balasubramanian
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks
 
Back
Top