0

i have a problem with copying my new tabview based on a selection from a griditem the code that i use is:

string selectedcel = Grid_Werk.CurrentRow.Cells[2].Value.ToString();
int tabnumber = Tab_overview.TabPages.Count;
TabPage newtab = new TabPage();
newtab = Tab_Werkbon;

Tab_overview.TabPages.Insert(tabnumber , newtab);
Tab_overview.TabPages[tabnumber].ImageIndex = 7;
Tab_overview.TabPages[tabnumber].Text = selectedcel ;

when i click for the first time this will do the trick but then when i press for another item from the list both of the tabs are empty.

  • If `Tab_Werkbon` is already in the tabs list, it is not added again. You need to duplicate/clone it... Because after creating a new tab, you set newtab to point to an old, so you lost this new tab and the line with the `new TabPage` is useless. –  Jul 04 '20 at 19:40
  • Found that: https://stackoverflow.com/questions/14507173/copy-tabcontrol-tab –  Jul 04 '20 at 19:46
  • What are you targetting: Winforms, WPF, ASP..? YOU should __always__ TAG your questions correctly so one can see it on the questions page! – TaW Jul 04 '20 at 19:57
  • There is no such thing as a TabView. Always call things by their right name!! – TaW Jul 04 '20 at 19:58
  • I saw that tabview may be an old xaml control but I'm not sure it is that... https://learn.microsoft.com/en-us/windows/communitytoolkit/controls/tabview –  Jul 04 '20 at 20:44

0 Answers0