Your description is a little messy...however, from what I gathered from it, you have a checklistbox on a form and you want to update it whenever an event is triggered (via your delegate method)
Something like this would work:
public void AddToList(List<DirectoryInfo> di, string mypath)
{
mypath = null // if you need to set this to null do it outside the loop so it is only done once
try
{
foreach (DirectoryInfo info in di)
{
DirInfoCheckedListItem cb = new DirInfoCheckedListItem(info);
checkedListBox4.Items.Add(cb);
}
}
catch (Exception ex)
{
MessageBox.Show(w.Message);
}
}
public class DirInfoCheckedListItem
{
private DirectoryInfo info;
public DirInfoCheckListBoxItem(DirectoryInfo info)
{
this.info = info;
}
public string Text { get { return this.info.Name; } }
public object Tag { get { return this.info; } }
public override string ToString()
{
return this.Text;
}
}
James
2009-07-27 11:39:25