在我的项目中,在一个表单中tabcontrol中有两个列表视图,我无法将焦点设置为列表视图项。我使用以下代码。问题是我能够在两者中只选择一个列表视图。请告诉我,我可以选择在表格中选择两个列表视图。
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
BindData1();
if (listViewClients.Items.Count > 0)
{
listViewClients.Items[0].Selected = true;
listViewClients.Select();
}
if (listView1.Items.Count > 0)
{
listView1.Items[0].Selected = true;
listView1.Select();
}
}
答案 0 :(得分:0)
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
BindData1();
switch (this.tabControl1.SelectedTab.Name)
{
case "tpUpdate":
listViewClients.Items[0].Selected = true;
listViewClients.Select();
break;
case "tpDelete":
listView1.Items[0].Selected = true;
listView1.Select();
break;
}
}