list view sub item problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi all this is very strange. i add list view sub item to list view item and
then list view item to list view. when i add sub item to list view item once
there seems to be 2 subitem on the list viewitem. 1st itts the listview item
text 2 the list view sub item text.

wheni add the list view item to list view it loosted the listviewsub item
text property value.

i have no idea why that happen. can any one help

i use vs 2003 CF ver 1.4 sp3

also bellow is the code i am using. this code is in side a for each loop
with data row being the itterative object

thanks for your tiem
************************************************************


System.Windows.Forms.ListViewItem.ListViewSubItem lViewSubItm = new
System.Windows.Forms.ListViewItem.ListViewSubItem();
lViewSubItm.Text = drowAMC[4].ToString();



System.Windows.Forms.ListViewItem lViewItm = new
System.Windows.Forms.ListViewItem();
lViewItm.Text=drowAMC[0].ToString();
lViewItm.Checked=bool.Parse(drowAMC[1].ToString());

lViewItm.SubItems.Add(lViewSubItm);
this.lview.Items.Add(lViewItm);
 
What a mess with listitems and subitems...I have not understand you
very much. Could you explain it again a little more bit clearly?
Meanwhile, could you try changing the order this way?

this.lview.Items.Add(lViewItm);
lViewItm.SubItems.Add(lViewSubItm);

VS.NET 2005 Beta2?

Regards.
 
hello

what i an trying to do is to add a list view item to liest view and list
view sub item to list view item


thanks
 
Hi chamal,

the same occurs to me in these 2 little examples I've tried. Both of
them do not work:

Example1:

ListViewItem lvitem = new ListViewItem(new string[] { "peter, manolo,
john"});
lvitem.Text = "HELLO";
lv.Items.Add(lvitem);

Example2:

ListViewItem lvitem = new ListViewItem();
lvitem.Text = "HELLO";
ListViewItem.ListViewSubItem subitem = new
ListViewItem.ListViewSubItem();
subitem.Text = "PETER";
lvitem.SubItems.Add(subitem);
lv.Items.Add(lvitem);

I think I'm not able to help you.

Regards.
 
How many columns have you added to your ListView? You need as many columns
as subitems that you expect to add?

Your code snippet works for me so if you are still having problems feel free
to post your complete project.

Cheers
Daniel
 
Back
Top