Thanks, I checked out the debugging info and saw that Tag was not even showing up in it, so I created another class to extend the TabPage and added an IsFileReadOnly variable and it seems to work fine now.
Cory Borrow
Posts
-
Problem I can't get past. -
Problem I can't get past.It shows that it selected has a TabPage I can view all the info for that tabpage and everything though the debugger. It's weird that it stops and that line though, it skips the rest of the places where I have used
tabControl1.SelectedTab
. -
Problem I can't get past.I have an application it is tabbed based and holds a texteditor in each tab (The ICSharpCode TextEditorControl). I can open as many tabs as I want but when I switch bewteen 2 or three tabs I get this error. I'm am getting "Object reference not set to an instance of an object" result back. Problay somthing small I am missing somewhere, but I can't see where. Below is the code for when a tab switches.
void TabControl1SelectedIndexChanged(object sender, EventArgs e) { if(tabControl1.TabPages.Count > 0 && !tabControl1.SelectedTab.Disposing) { openFile = tabControl1.SelectedTab.ToolTipText; if(lengthSet == false) { if(oldLength != tabControl1.SelectedTab.Controls["textEditorControl1"].Text.Length) oldLength = tabControl1.SelectedTab.Controls["textEditorControl1"].Text.Length; if((bool)tabControl1.SelectedTab.Tag == true) { saveToolStripMenuItem.Enabled = false; toolStripButton3.Enabled = false; } else { saveToolStripMenuItem.Enabled = true; toolStripButton3.Enabled = true; } } } lengthSet = false; }
The Lineif((bool)tabControl.SelectedTab.Tag == true)
returns the error If I addTextEditorControl editor = (TextEditorControl)tabControl1.SelectedTab.Controls["textEditorControl1"];
and replace the line with the error withif(editor.IsReadOnly)
It still returns the same thing. -
Retreving text from treeview problem. [modified]Ok, I have a treeview and it has the following items in it. Menu 1 Sub menu 1 Then I call a function to write the items to a file. But when I open the file it shows Menu 1 Menu 1 Sub menu 1 Anyone know why it is creating the other Menu item? Here are the functions. menu += WriteMenu(menu, treeView1); string WriteMenu(string menu, TreeView treeView) { foreach(TreeViewMenuItem menuItem in treeView.Nodes) { if(menuItem.Nodes.Count > 0) { menu += menuItem.Text + "\n"; menu += WriteSubMenu(menu, menuItem); } else { menu += menuItem.Text + "\n"; } } return menu; } string WriteSubMenu(string menu, TreeViewMenuItem menuItem) { foreach(TreeViewMenuItem subItem in menuItem.Nodes) { if(subItem.Nodes.Count > 0) { menu += subItem.Text + "\n"; menu += WriteSubMenu(menu, subItem); } else { menu += subItem.Text + "\n"; } } return menu; } -- modified at 20:47 Monday 4th June, 2007