Click here to Skip to main content
15,881,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi


I want to pass date from a form to another using delegate. This is the code :
C#
public delegate void delEditareContact(ListViewItem text);
            delEditareContact nume = new delEditareContact(ec.NumeData);
            nume(this.LWContacte.Items[0]);


            delEditareContact nr_telefon = new delEditareContact(ec.NrTelefonData);
            nr_telefon(this.LWContacte.Items[0].SubItems[1]);


The bolded text is the problem.. I think i can't pass a subitem of a listview, only items..

Please help me in this regard!


the error is: cannot convert from 'System.Windows.Forms.ListViewItem.ListViewSubItem' to 'System.Windows.Forms.ListViewItem'
Posted
Updated 29-Apr-11 0:15am
v4
Comments
Olivier Levrey 29-Apr-11 6:15am    
Edited tags.

The error you get is pretty straight forward. Either change the delegate to accept ListViewITem or pass the value of the this.LWContacte.Items[0].

What's the problem?
 
Share this answer
 
Comments
Ryan Zahra 29-Apr-11 6:14am    
Same thoughts. My 5.
CodeHawkz 29-Apr-11 6:56am    
:) Thanks
RaviRanjanKr 29-Apr-11 14:37pm    
Nice Answer! My 5 :)
You should either pass the ListViewItem by call the method in the following manner:
nr_telefon(this.LWContacte.Items[0]);


Else you should modify the delegate to have accept a parameter of type ListViewSubItem:
public delegate void delEditareContact(ListViewSubItem text);
 
Share this answer
 
Comments
RaviRanjanKr 29-Apr-11 14:37pm    
Nice Answer! My 5 :)
I find out why .. I must create another delegate for the subitems like this:

public delegate void delEditareContactSubItem(ListViewItem.ListViewSubItem text);
 
Share this answer
 
I would alternatively advise a more robust an non-intrusive method of inter-form collaboration based on the interface implemented by a form.

Please see this discussion (including my answer):
How to copy all the items between listboxes in two forms[^].

—SA
 
Share this answer
 
v2

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