473,657 Members | 2,540 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ListViewItem property ListView

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
ListViewItemCol lection 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
Nov 16 '05 #1
2 6998

"Chuck" <ce*****@austin .rr.com> wrote in message
news:3x******** *********@fe1.t exas.rr.com...
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
ListViewItemCol lection 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);
}
}
--
Mickey Williams
Author, "Visual C# .NET Core Ref", MS Press
www.neudesic.com
www.servergeek.com
Nov 16 '05 #2
Thanks for the help.
Reflector is very helpful. For anyone else interested you can find it at:
http://www.aisto.com/roeder/dotnet/ along with some other utilities I
haven't tried, but look interesting.

Chuck

"Mickey Williams [C# MVP]" <my first name at servergeek dot com> wrote in
message news:uf******** ******@TK2MSFTN GP12.phx.gbl...

"Chuck" <ce*****@austin .rr.com> wrote in message
news:3x******** *********@fe1.t exas.rr.com...
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
ListViewItemCol lection 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);
}
}
--
Mickey Williams
Author, "Visual C# .NET Core Ref", MS Press
www.neudesic.com
www.servergeek.com


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1870
by: LV | last post by:
Hello, I would like to manually set one of my list view items as selected. When this item is set, I would like for a method to execute. I have a delegate on the list view for SelectedIndexChanged. For some reason, when I set the listviewitem.Selected = true, the event is not fired. Here is my code: using System; using System.Windows.Forms; namespace DOMBuilder.GUI { public delegate void SelectedDomainObjectChangedHandler();
6
13092
by: grs | last post by:
The following is a code example from the Microsoft MSDN. My question is on the following three lines of code: ListViewItem item1 = new ListViewItem("item1",0); ListViewItem item2 = new ListViewItem("item2",1); ListViewItem item3 = new ListViewItem("item3",0); You would in most cases know the ListViewItem name or the number of items to create (item1,item2 etc). How would you create this individual rows programmatically ?
2
3700
by: Fritz | last post by:
I know it, I know it. It's come up a lot. I've done the Googling, but the standard answer doesn't do what I expect it to. For the record, the standard answer is: "Set the Selected property of a ListViewItem to true." I also know from MSDN that the selection won't really take effect until the ListView has focus. My specific problem is that setting item.Select = true doesn't actually select my item (or at least, doesn't highlight it). I'm...
2
1443
by: naikrovek | last post by:
Hello all. I have a ListView on a form, that has columns added at design-time but will be populated run-time. So, I know what the columns will be, and I know that I will have an arbitrary number of 'rows' in the ListView, anywhere from 1 to 100 or even 1000. The purpose of the program is to allow a user to keep an eye on tickets in a ticketing database.
1
4251
by: LagartijaNick | last post by:
Question: I have a ListView in which I'm selecting a ListViewItem based on the value of a textbox. On my XP machine (with default color scheme) the ..Selected row is a noticable grey (back color of ListView is white). However, on a custom Win2K desktop, the selected item is a faint grey and the users can barely see the highlighted row. The custom desktop settings have been locked down (ie. cannot be changed via Control Panel etc.)
2
3936
by: Kela | last post by:
An interesting problem: I have a ListView with LabelEdit set to TRUE. When I change the label, I want to make some decisions as to whether the ListViewItem (that's just been edited) should stay in the ListView or not. The natural place to inspect this is in the AfterLabelEdit event... If the decision is to take the item out, I used the ListViewItem.Remove(). However - check this out: A) say that the item's index is N (indices are...
13
10213
by: deciacco | last post by:
How can I have access to the items collection of a listview control on my form from a background thread? I know I need delegates to update the listview control and I have those calls in the foreach loop, but I'm not sure how to access the items collection. foreach (ListViewItem li in this.listview1.Items) { Invoke(new deleg(updatectrl), new object { param });
10
3514
by: Gav | last post by:
I am trying to have a ListView to dispay a list of names and want to have an id stored within the list but not visable. I have tried to go about doing this by using the ListViewItem and setting the Text and Tag properties. Problem is when I add the ListViewItem to the ListView I get the following ListViewItem: {Test1} ListViewItem: {Test2} ListViewItem: {Test3}
2
6148
by: witpo | last post by:
Hi, I would like to display all listview items in one row with scroll bar below it – instead of multiple rows and scroll bar on the right. Someone told me that I can achieve it using LVM_SETITEMPOSITION message. According to my knowledge code below should set position for each item added to listView control. There are two ways of doing it - we can use MessageWindow.SendMessage from Microsoft.WindowsCE.Forms or use DllImport and SendMessage....
0
8425
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8326
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8845
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8522
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8622
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1736
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.