ListView how to change text

A

arcade2084

I need to change the text of my listview item (not a subitem) the
control will not have the current focus. I have tried the following
without any luck:

ListView1.Items[0].Text = "XXXX";

This does not work - please help!

Thanks,
Chris
 
A

arcade2084

OK Maybe I need to be clearer:

function()
{
listView1.Items.Add("test");
}

function2()
{
listView1.Items[0].Text = "new test";
}

this is what is not working...


When I do this it works fine:

listView1.Items.Add("test");
listView1.Items[0].Text = "new test";

The text appears correctly as "new test".


Kelly S. Elias
Webmaster
http://devdistrict.com



I need to change the text of my listview item (not a subitem) the
control will not have the current focus. I have tried the following
without any luck:

ListView1.Items[0].Text = "XXXX";

This does not work - please help!

Thanks,
Chris
 
C

Claes Bergefall

I see nothing wrong with that code. Where are you calling these functions?
What is the value of listView1.Items[0].Text inside function2 (set a
breakpoint and examine the value before and after)?

/claes

OK Maybe I need to be clearer:

function()
{
listView1.Items.Add("test");
}

function2()
{
listView1.Items[0].Text = "new test";
}

this is what is not working...


When I do this it works fine:

listView1.Items.Add("test");
listView1.Items[0].Text = "new test";

The text appears correctly as "new test".


Kelly S. Elias
Webmaster
http://devdistrict.com



I need to change the text of my listview item (not a subitem) the
control will not have the current focus. I have tried the following
without any luck:

ListView1.Items[0].Text = "XXXX";

This does not work - please help!

Thanks,
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top