Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 1 listview with 3 colum(name, value and status).I want to add a label with background to present status of name following each row. but I do not it.
everyone help me please.
thanh you very much!
Posted

Firstly you question is not very clear.

You cannot add a textbox in a subitem of a listview.
But if you want to add subitems of a listview then you can use some code like
Dim pItem As ListViewItem
pItem = New ListViewItem
pItem.UseItemStyleForSubItems = False 'Use this line to style subitem
pItem.Text = "Text"
pItem.SubItems.Add("Subitem1")

pItem.SubItems(1).BackColor = Color.Red 'Use this line to change back color

Listview1.Items.Add(pItem)

And you need to set the View property of the listview to Details
 
Share this answer
 
v2
Comments
Dalek Dave 18-Nov-10 7:20am    
Good Call.
Sandeep Mewara 18-Nov-10 12:21pm    
Comment from OP:
no. My Require is add a label into column status of listview . if this listview have 100 rows, I must 100 labels.the Label is added is the subItems.
can you help me resolved this problem?
thanks.
 
Share this answer
 
You do not want to do that. Creating a control is an expensive operation and creating a hundred of them takes a while. It also slows down scrolling of the ListView box.

If the labels do not move, the but text of each items has to, scrolling will be all but impossible and EXTREMELY slow to update.

I would instead, add another subitem to the data with the status information and probably ownerdraw the ListView to accomodate what you want.
 
Share this answer
 
your idea is also good. but how is the way? because my application is a listview which have 3 columns(student,value,status).i want to when value=1,color of status is red and value =0 is color of status is while.So i want to add a rectangle lable(with backcolor is red or while depend on value)to subitems of listview.

note: I coded for my application by listview so if change listview by other control I must repair all code in my application and I won't this

If you know, help me by some code lines.please!
thanks
 
Share this answer
 
Comments
Goutam Patra 19-Nov-10 3:13am    
First dont push answer to add a comment. Use add comment instead. Now as per your requirment see my answer. I have edited the same.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900