有没有办法通过它的文本获取标签页
Is there a way to get tab page by it's text
我正在更改标签控件中标签页的文本(重命名标签),我想通过它的文本访问标签页。问题是,这些页面是用代码创建的,我无法通过它们的名称访问它们
var yourtabs = tabControlFEPages.Controls
.OfType<TabPage>()
.Where(tab => tab.Name.Equals(cmbFEEdytujKarteWybierzKarte.Text))
.ToList();
var index = tabControlFEPages.TabPages.IndexOf(yourtabs[0]).ToString();
MessageBox.Show(index);
foreach (TabPage tab in yourtabs)
{
MessageBox.Show(tab.ToString());
}
tabControlFEPages.TabPages[index].Text = txtFEEdytujKarteNowaNazwa.Text;
这就是我想要的:
var yourtabs = tabControlFEPages.Controls.OfType<TabPage>().Where(tab =>
tab.Text.Equals(cmbFEEdytujKarteWybierzKarte.Text)).ToList();
var index = tabControlFEPages.TabPages.IndexOf(yourtabs[0]);
if (!string.IsNullOrEmpty(txtFEEdytujKarteNowaNazwa.Text))
tabControlFEPages.TabPages[index].Text =
txtFEEdytujKarteNowaNazwa.Text.ToString();
我正在更改标签控件中标签页的文本(重命名标签),我想通过它的文本访问标签页。问题是,这些页面是用代码创建的,我无法通过它们的名称访问它们
var yourtabs = tabControlFEPages.Controls
.OfType<TabPage>()
.Where(tab => tab.Name.Equals(cmbFEEdytujKarteWybierzKarte.Text))
.ToList();
var index = tabControlFEPages.TabPages.IndexOf(yourtabs[0]).ToString();
MessageBox.Show(index);
foreach (TabPage tab in yourtabs)
{
MessageBox.Show(tab.ToString());
}
tabControlFEPages.TabPages[index].Text = txtFEEdytujKarteNowaNazwa.Text;
这就是我想要的:
var yourtabs = tabControlFEPages.Controls.OfType<TabPage>().Where(tab =>
tab.Text.Equals(cmbFEEdytujKarteWybierzKarte.Text)).ToList();
var index = tabControlFEPages.TabPages.IndexOf(yourtabs[0]);
if (!string.IsNullOrEmpty(txtFEEdytujKarteNowaNazwa.Text))
tabControlFEPages.TabPages[index].Text =
txtFEEdytujKarteNowaNazwa.Text.ToString();