我有这个listivew的问题。当我双击它时,它应该向我显示我单击的行的第一个单元格的信息对话框,并且效果很好。
现在的问题是,如果我继续单击行,我仍然会从我单击的先前行中获得对话框。
I click a random row 1 time: Shows me dialog
I click another random row: Shows me dialog from the first row I clicked, then when I close said dialog it shows me the dialog of info of the row I clicked.
I click another random row: Shows me dialog from the first row I clicked and from the second one.
..它继续
这是代码:
private void listViewPlayers_MouseDoubleClick(object sender, MouseEventArgs e)
{
string
pUser = "";
int
pID = -1;
pID = Convert.ToInt32(listViewPlayers.SelectedItems[0].SubItems[0].Text);
pUser = listViewPlayers.SelectedItems[0].SubItems[1].Text;
bw.WorkerReportsProgress = true;
bw.DoWork += new DoWorkEventHandler
(
delegate(object o, DoWorkEventArgs args)
{
BackgroundWorker b = o as BackgroundWorker;
pInfo = pInfoClient.DownloadString("get info from web").Trim();
}
);
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler
(
delegate(object o, RunWorkerCompletedEventArgs args)
{
if (strcmp(pInfo, "ERROR"))
{
MessageBox.Show("There was an error retrieving user information!\nPlease try again later..", "Error");
return;
}
string[]
iSplit = pInfo.Split(new char[] { (char)'|' }, System.StringSplitOptions.RemoveEmptyEntries);
playerInfo iInfo = new playerInfo(pUser, pID, iSplit);
iInfo.ShowDialog();
}
);
bw.RunWorkerAsync();
}
请原谅我对问题的解释,我对此很糟糕。