C#TabControl文件找不到

发布于 2025-01-26 22:39:14 字数 1026 浏览 2 评论 0 原文

我有一个我不明白的问题。我有一个带有2个选项卡的TabControl。

选项卡1:Tab 1 in IT选项卡

2:Tab 2:在TAB 2中使用ChecllistBox的选项卡

,我在TAB 2中,我在没有问题的情况下运行此代码:

foreach (int i in groupeCheckedListBox.CheckedIndices)
{
    groupeCheckedListBox.SetItemCheckState(i, CheckState.Unchecked);
}

但是,如果我在选项卡1中,它找不到ChecklistBox因此,我决定编写此代码:

if (tabControl1.SelectedTab == tabControl1.TabPages[1])
{
    foreach (int i in groupeCheckedListBox.CheckedIndices)
    {
        groupeCheckedListBox.SetItemCheckState(i,CheckState.Unchecked);
    }
}

但是当我运行它时,我会收到一个错误:

“ system.componentmodel.win32 exception :'le fichierspécifiéest in Intouvable'

意味着它无法在行中找到文件” if(tabcontrol1.selectedtab == tabcontrol1.tabcontrol1.tabpages [1])。

tabControl1.SelectedTab = tabControl1.TabPages[1];

TabPage t = tabControl1.TabPages[0];
tabControl1.SelectTab(t);

以相同的结果

来解释我为什么找不到文件?

I have a problem that I don't understand. I have a tabcontrol with 2 tabs in it.

Tab 1: tab with datagridview in it

tab 2: tab with checklistbox in it

When I'm in the tab 2, I run this code without a problem:

foreach (int i in groupeCheckedListBox.CheckedIndices)
{
    groupeCheckedListBox.SetItemCheckState(i, CheckState.Unchecked);
}

but if I'm in the tab 1, it doesn't find the checklistbox so I decided to write this code:

if (tabControl1.SelectedTab == tabControl1.TabPages[1])
{
    foreach (int i in groupeCheckedListBox.CheckedIndices)
    {
        groupeCheckedListBox.SetItemCheckState(i,CheckState.Unchecked);
    }
}

but when I run it, I receive an error:

"System.ComponentModel.Win32Exception : 'Le fichier spécifié est introuvable'

which mean that it cannot find the file at the line "if (tabControl1.SelectedTab == tabControl1.TabPages[1])".

I also tried to go with:

tabControl1.SelectedTab = tabControl1.TabPages[1];

and

TabPage t = tabControl1.TabPages[0];
tabControl1.SelectTab(t);

with the same result.

Can someone explain me why it doesn't find the file please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

攒一口袋星星 2025-02-02 22:39:14

Winforms中的HMMM选项卡控件可能很棘手,您是否将此逻辑放在选项卡康德罗(TabControl)上的SelectedIndexchanged事件中?然后,您应该能够检查索引值并确定您有活动的选项卡,并且每个选项卡中的控件都应始终可访问和实例化,我能够将SelectedTab检查到预期的TabPage,并评估为true:

Hmmm tab controls in Winforms can be tricky, are you putting this logic in the SelectedIndexChanged event on the TabControl? Then you should be able to check the index value and determine which tabPage you have active and the controls in each tab should always be accessible and instantiated, I was able to check the selectedTab to the tabPage expected and it evaluated true:enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文