我试图在选择新标签时清除列表框的内容。这就是我得到的,但没有任何反应。
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedTab == tabControl1.TabPages["entryTab"])
{
readBox.Items.Clear();
reminderBox.Items.Clear();
}
}
答案 0 :(得分:1)
在表单加载
中尝试这样的操作 tabControl1.Selecting += new TabControlCancelEventHandler(tabControl1_SelectedIndexChanged);
答案 1 :(得分:0)
// Try this set null to DataSource
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedTab == tabControl1.TabPages["entryTab"])
{
readBox.DataSource = null;
reminderBox.DataSource = null;
}
}