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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top