G
Guest
Here's a strange one.
I have a screen with a listView on it, in Details view, which basically
shows a list of customers.
If I click on one of these customers, a second screen appears, showing
details about that customer. Click on OK, and it returns to the listview
screen.
I add a simple function to the ListView's SelectedIndexChanged
event, which checks to see which item has been clicked on, and
then displays the second (Customer Details) screen:
private void lvCustomers_SelectedIndexChanged(object sender,
System.EventArgs e)
{
int m_selectedRow = -1;
for (int n=0; n<lvServiceReqs.Items.Count; n++)
if (lvServiceReqs.Items[n].Selected)
m_selectedRow = n;
if (m_selectedRow == -1)
return;
// I have a DataSet, dsCustomers, which contains one record
// per row shown in the ListView
m_selectedCustomerId =
int.Parse(dsCustomers.Tables[0].Rows[m_selectedRow].ItemArray[1].ToString());
frmCustomerDetails dlg = new frmCustomerDetails(m_selectedCustomerId);
dlg.ShowDialog();
}
When I click on a customer, no problem, the second screen appears.
I can click on OK and return to the List screen.
But if I try to click on a second customer, it seems to ignore the
click. Clicking a *second* time works okay though - it'll then show
details of the second customer I clicked on.
Click on OK on the customer details screen, and once again, the
list view appears, clicking on a customer will be ignored, but click
again, and it'll work okay.
This works fine when using the DataGrid control... why does
this problem occur with ListViews ?
Michael
Bristol, UK
I have a screen with a listView on it, in Details view, which basically
shows a list of customers.
If I click on one of these customers, a second screen appears, showing
details about that customer. Click on OK, and it returns to the listview
screen.
I add a simple function to the ListView's SelectedIndexChanged
event, which checks to see which item has been clicked on, and
then displays the second (Customer Details) screen:
private void lvCustomers_SelectedIndexChanged(object sender,
System.EventArgs e)
{
int m_selectedRow = -1;
for (int n=0; n<lvServiceReqs.Items.Count; n++)
if (lvServiceReqs.Items[n].Selected)
m_selectedRow = n;
if (m_selectedRow == -1)
return;
// I have a DataSet, dsCustomers, which contains one record
// per row shown in the ListView
m_selectedCustomerId =
int.Parse(dsCustomers.Tables[0].Rows[m_selectedRow].ItemArray[1].ToString());
frmCustomerDetails dlg = new frmCustomerDetails(m_selectedCustomerId);
dlg.ShowDialog();
}
When I click on a customer, no problem, the second screen appears.
I can click on OK and return to the List screen.
But if I try to click on a second customer, it seems to ignore the
click. Clicking a *second* time works okay though - it'll then show
details of the second customer I clicked on.
Click on OK on the customer details screen, and once again, the
list view appears, clicking on a customer will be ignored, but click
again, and it'll work okay.
This works fine when using the DataGrid control... why does
this problem occur with ListViews ?
Michael
Bristol, UK