I am attempting to change to a tab dependent on a treeView node selection:
e.g.
private void hostView_AfterSelect(object sender, TreeViewEventArgs e)
{
string selectedNodeText = e.Node.Text;
// MessageBox.Show(selectedNodeText);
tabControl1.SelectTab(selectedNodeText);
}
Although when the method runs it returns the following:
tabControl1.SelectTab(selectedNodeText); >> Value cannot be null.
selectedNodeText is definitely a value / not null, as I tested it using MessageBox.Show
Assuming the text of your selected node is not null, you’ll have to set the
Nameproperties of yourTabPagesif you use theSelectTabmethod that takes a string as input.Set
Nameproperties of your TabPages with same values asTextproperties of your nodes.EDIT:
MSDN is a great resource for developers. In your particular case, when receiving an
ArgumentNullException, you should have tried to read the documentation of theSelectTabmethod.