Senne Machtelinckx Senne Machtelinckx - 1 year ago 77
C# Question

How to get value of a string out of Listview

I have a listview called lvNotities with some values in it from the class Notes.
The values in the listview come from the list: public ObservableCollection Mappen = new ObservableCollection();

public class Notes
public ObservableCollection<Notes> Mappen = new ObservableCollection<Notes>();
private string titel;
public string Titel
get { return this.titel; }
if (this.titel != value)
this.titel = value;

public event PropertyChangedEventHandler PropertyChanged;

public void NotifyPropertyChanged(string propName)
if (this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs(propName));

For example:

  • One

  • Two

  • Three

Click code:

StreamWriter outputStream = File.CreateText(Convert.ToString(lvNotities.SelectedItem) + ".txt");

So when I double click the item, I want a document to be made with the name for example:

But when I do it, the document is saved as :

I know the explanation is bad but hopefully someone knows what I want.

Answer Source

Does this work?

StreamWriter outputStream = File.CreateText(((Notes)lvNotities.SelectedItem).Titel + ".txt");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download