copy object attributes
-
Hi all, in VB2005, how can I asssign the whole object attributes to another object of the same type. For example, if through the code I've assigned the attributes of a DataGridView object (AllowUserToddrows, ...), is there any way to copy them to another Datagridview object? Thanks in advance, Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
-
Hi all, in VB2005, how can I asssign the whole object attributes to another object of the same type. For example, if through the code I've assigned the attributes of a DataGridView object (AllowUserToddrows, ...), is there any way to copy them to another Datagridview object? Thanks in advance, Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
I've never had the need to do this, so a litte research is in order... There's no way to copy a DGV in one line of code, no. The most correct way to do this would be to put the code that setups up your grid properties into a shared method, then just pass the datagrid object you want setup by refrence. Done. No need to copy the object. Other than that, you'd have to create a method that takes a DGV ByRef as a parameter, then code it to create a new DGV object, copy all the properties you want from the supplied DGV to the new one, then return the new object as a return value. [EDIT] You could probably do this with Reflection though. -- modified at 12:32 Wednesday 16th May, 2007
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007