473,614 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to change text of ListViewItem

I have a ListView with 4 columns that shows in details mode.

How do I change the text of one of the columns of a specific item if I
know the index I want to change at?

mylistview.Item s[index].Tag
returns a null reference exception if I attempt to use it.

I am displaying data that changes in real time and needs to have
certain columns update when a separate thread invokes an
UpdateMyColumn( int index, string newText) method on the form.

Should I be using a different control, instead?

Feb 23 '07 #1
3 2672
ListView listView;

listView.Items[index].SubItems[index1].Text = "your text";

"bthetford" <br*****@dodeca tec.comwrote in message
news:11******** **************@ t69g2000cwt.goo glegroups.com.. .
>I have a ListView with 4 columns that shows in details mode.

How do I change the text of one of the columns of a specific item if I
know the index I want to change at?

mylistview.Item s[index].Tag
returns a null reference exception if I attempt to use it.

I am displaying data that changes in real time and needs to have
certain columns update when a separate thread invokes an
UpdateMyColumn( int index, string newText) method on the form.

Should I be using a different control, instead?

Feb 23 '07 #2
Strange.
I used to get a nullreferenceex ception out of that, as well.
I must have had an off-by-one error.

Thanks.

Feb 24 '07 #3
Well, there must be no SubItems added to the ListItem.Subite ms collection.

It's not enough to just create columns in the ListView. For each added item
you need to

ListView.Items[index].SubItems.Add( "lalala" );

Then you can change their text as described.

"bthetford" <br*****@dodeca tec.comwrote in message
news:11******** *************@s 48g2000cws.goog legroups.com...
Strange.
I used to get a nullreferenceex ception out of that, as well.
I must have had an off-by-one error.

Thanks.

Feb 24 '07 #4

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

Similar topics

2
12386
by: TF | last post by:
Hi, Is there any way to change the text color of SOME of the ListBox(Windows Forms Control) items in VB.NET? TF
2
2147
by: Jasim Iqbal | last post by:
hi all i ran into thi sproblem this monday and still havent been able to figure out why the list view control is not showing the complete text string the original strings i want to be displayed in the list view are more than 350 chars long, but it only displays 259 chars of each string. BUT when i extract the string values from the control it DOES give me complete strings. i have tried to increase the column width but nothing happens ...
5
5327
by: Park | last post by:
In the multiple line textbox, is it possible that every sentences shows different color ? For example, test sentence 1 : red test sentence 2 : blue ....
6
13089
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 ?
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.)
3
4871
by: Steve Long | last post by:
I hope this isn't too stupid of a question but I'm looking for a way to change an item in a listview control when the mouse moves over it. I'd like to change its color and underline it for a probable internet link. Is there a way to do that? I've looked through the help and can't find anything that, well, helps. Perhaps I'm using the wrong control. Any help would be appreciated. Thanks Steve
0
1597
by: garyusenet | last post by:
I am trying to create a form that will display a list of open internet explorer windows and allow the user to choose one of them. So far I have created an arraylist which contains all of the open internet explorer windows. In the for() part of the code below I have tried to create a listviewitem for each window of internet explorer open (i.e. each element of the arraylist). However it's not working. I don't seem to have access to IE's...
7
7342
by: Pantokrator | last post by:
Hi, I've searched the web and MSDN but couldn't find adequate information on retrieving the text of a subitem of a listviewitem. What I want to do is simple. I have a listview control with 2 columns and a large number of listviewitems. Every time I click on a row (one of the listviewitems), I would like to get the String* representation of the second column cell. First I get the index as follows:
2
3743
by: jmDesktop | last post by:
I have two listview controls. I have three items of text. I can drag and drop the listview items between each other, back and forth. But the images from the imagelist do not copy over from listview1 to listview2, only the text does. Both listviews have their smallimagelist as the single imagelist I have. Here is my code and thank you for any help. private void listView1_ItemDrag(object sender, ItemDragEventArgs e) { int max =...
0
8198
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
8642
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
8294
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
8444
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...
0
7115
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4058
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4138
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1438
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.