我正在使用以下代码:
private void listBox1_MouseClick(object sender, MouseEventArgs e)
{
txtFrom.Clear();
txtSubject.Clear();
txtBody.Clear();
something = this.listBox1.SelectedIndex.ToString();
int something1 = Convert.ToInt32(something);
foreach (MailMessage email in messages)
{
count++;
if (count == something1)
{
txtFrom.Text = email.From.ToString();
txtSubject.Text = email.Subject.ToString();
txtBody.Text = email.Body.ToString();
}
}
问题是,当我选择另一个项目时,txtFrom.Text、txtSubject.Text、txtBody.Text 的值不会根据列表框中选择的新值而改变。