ListViewItem property ListView

  • Thread starter Thread starter Chuck
  • Start date Start date
C

Chuck

The ListViewItem class contains a readonly property called ListView which
returns the item's containing ListView object.

I have not been able to figure out how this value is set. The
ListViewItemCollection class Add method has to be able to set this value,
but ListViewItem does not expose any public or protected methods/properties
that support setting the value.

I have looked for Rotor source code for the classes, but haven't been able
to find any.

The reason I want this information is to use it as an example of how to
write my own classes that support the item knowing its container. This
information has to be readonly to external users. Setting the container
value for the item has to occur within the Add method of the container.

Thank you for your help

Chuck
 
Chuck said:
The ListViewItem class contains a readonly property called ListView which
returns the item's containing ListView object.

I have not been able to figure out how this value is set. The
ListViewItemCollection class Add method has to be able to set this value,
but ListViewItem does not expose any public or protected methods/properties
that support setting the value.

The ListViewItem class includes an internal method called Host, which is
called by the ListView when the item is inserted into the list view.
I have looked for Rotor source code for the classes, but haven't been able
to find any.

Rotor doesn't have any System.Windows.Forms types. Use Reflector.
The reason I want this information is to use it as an example of how to
write my own classes that support the item knowing its container. This
information has to be readonly to external users. Setting the container
value for the item has to occur within the Add method of the container.

class X
{
Box _box = null;
internal void SetBox(Box box)
{
_box = box;
}

public Box Box
{
get { return _box; }
}
}

class Box
{
public void Add(X x)
{
x.SetBox(this);
}
}
 
Back
Top