我一直在为这个问题而烦恼,我的 ToString 是一个接一个地重复,而不是掉到下一行。
如图所示,第二个事件名称应该在下面的行中。
//ToString method in Event Class
public override string ToString()
{
return "\nEvent name : " + m_evName + "\n Date :" + m_evDate + "\n";
}
//print method in class
public String PrintEvents()
{
StringBuilder retev = new StringBuilder("");
foreach (Event e in m_events)
{
retev.Append(e.ToString() + "\n");
}
return retev.ToString();
}
//Foreach that displays the text
private void cboListEv_SelectedIndexChanged(object sender, EventArgs e)
{
String SelectedVenue = cboListEv.Text;
List<Venue> found = plan.selectVen(SelectedVenue);
lstEvents.Items.Clear();
foreach (Venue v in found)
{
lstEvents.Items.Add(v.PrintEvents());
}
}