您无法将ChartType转换为字符串异常,因为您正在该帐户上调用foreach。名称字符串本身,它遍历帐户名中的每个字符。我重写了这个方法,以便正确地更新过滤器字符串的listBox1。
private void textBox4_TextChanged(object sender, EventArgs e)
{
if (Properties.Settings.Default.Accounts != null)
{
listBox1.BeginUpdate();
listBox1.Items.Clear();
if (!String.IsNullOrEmpty(textBox4.Text))
{
foreach (var account in Properties.Settings.Default.Accounts)
{
if (account.Name.Contains(textBox4.Text))
{
listBox1.Items.Add(account);
}
}
}
else
{
foreach (var account in Properties.Settings.Default.Accounts)
{
listBox1.Items.Add(account);
}
}
listBox1.EndUpdate();
}
}