ya i think that is what was happening too =P i just couldn't understand why if you made variable b equal to a, why changing b changed a... i could understand if b was a reference to a, that changing a would change b, but i would have never figured it to be the opposite x.x... in any case, i've found .equals() is the perfect solution... cause it allows me to copy the same specification as the tabpage, without changing the original ^^
jaman4dbz
Posts
-
.insert is inserting 2 entries instead of one... please help. -
.insert is inserting 2 entries instead of one... please help.thanks for the idea, i tried changing it to new tabpage(); then making the tabpage equal to my blanktabpage, but that didn't solve it. i also read the article, and although it isn't 100% clear to me right now, because of how many times he says value to reference and reference to value =P, i still figure theirs no way my blanktabpage is changing value, because it is initialized in load_form. ... ... OK IGNORE EVERYTHING I JUST SAID! i just tried creating a fresh tabpage, and new webbrowser, and setup the webbrowser and added it to the tabpage, then setup the tabpage and added it to the tabcontrol and that worked! no multipuls of tabpages!... i still have no idea how 2 tabpages were added from a single .insert call, but whatever XD thanks alot for your help alexander :D w00t i can finally finish my project!!!
-
.insert is inserting 2 entries instead of one... please help.tabControl1.TabPages.Insert(tabControl1.TabPages.Count, newtabpage); MessageBox.Show(Convert.ToString(tabControl1.TabPages.IndexOf(newtabpage)));
i use a breakpoint on the first line... and when i do, tabcontrol1.tabpages.count comes up as 5, therefor it should be inserting this new tabpage @ index 5... but the next line shows a messagebox, showing which index the tabpage i JUST added is at, and shows 0. the visual output of this, is that it creates 2 tabpages one at index 0, or at the front or left side, and one at the back or right. i don't understand how a single line of code could insert 2 tabpages... because of the breakpoint and messagebox i don;t think the rest of the function is relevant but i'll post it anyways, because i really just want some help on this.public void addatab(string title, string url, string tooltip) { TabPage newtabpage = blanktabpage; foreach (WebBrowser i in newtabpage.Controls) { i.Name = title; } newtabpage.Name = "tab" + title; newtabpage.Text = title; newtabpage.Tag = url; newtabpage.ToolTipText = tooltip; tabControl1.TabPages.Insert(tabControl1.TabPages.Count, newtabpage); MessageBox.Show(Convert.ToString(tabControl1.TabPages.IndexOf(newtabpage))); }
also i tried using .add first, and that produced the same thing... i used .insert so i could blatently point out the conundrum =P i've had the problem posted on microsofts site... msdn or something like thatm, but didnt get a response for a month... and i posted on my university forum, but the one person who kept helping me out, appears to be taking a break from the forums... so i've finally came here, because i know this place has some notbad tutorials and such, it's gotta have some smart people ;) also while im waiting i'll look more indepth of what exactly insert and add does for collections, to see if i can get an awnser there. FFXI ftw beatmania IIDX ftw Soccer ftw