Treeview, tag, assign objects 
Author Message
 Treeview, tag, assign objects

I've seen a few postings about the problem with assigning objects to activex
control tags (ie bug Q176392). MS says it is fixed in VB6. Here is a
solution for VB5 though that seems to work. Only for used defined classes
though.

The solution is to add your own default property to your class like:

    Public Property Get ObjectRef() As IUnknown
      Set ObjectRef = Me
    End Property

Choose    tools->procedure attributes->advanced and set procedure ID to
default.

Now we have a default poperty that returns an object ref!

Set the tag like:

  Dim nodX As Node
  Dim myObject As MyClass

  Set myObject = New MyClass

  Set nodX = TreeView1.Nodes.Add(, , "x", "x", "folder", "openfolder")
  nodX.tag = myObject

Use the tag like:

      Dim myObj As MyClass

      Set myObj = Node.tag
      myObj.PrintSomeInfo

/A



Sun, 22 Apr 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Problem with TreeView control Nodes and assigning objects to Tag property

2. Treeview, tag, howto assign object

3. Shouldnt treeview node.tag take object...

4. Setting TreeView Node.Tag to an object

5. Assigning new properties and methods to html tags

6. Assigning values to INPUT tags from ASP how?

7. Object using <OBJECT> tag

8. VBA-assigning an OLE-object to an Ole-object-field

9. Can Printer Object be assigned to an Object Variable

10. Assign OLE Object Of Crystal Report Object

11. Problem in assigning object to existing Item in Collection Object

12. Assign Object to Variant and then Variant to Object

 

 
Powered by phpBB® Forum Software