1

选择新选项卡时,我试图清除列表框的内容。这是我得到的,但没有任何反应。

 private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (tabControl1.SelectedTab == tabControl1.TabPages["entryTab"])
        {
            readBox.Items.Clear();
            reminderBox.Items.Clear();
        }
    }
4

2 回答 2

1

在表单加载中尝试这样的事情

   tabControl1.Selecting += new TabControlCancelEventHandler(tabControl1_SelectedIndexChanged);
于 2013-05-24T16:18:39.367 回答
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;
        }
    }
于 2013-05-29T15:21:36.700 回答