Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6172477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:23:59+00:00 2026-05-23T23:23:59+00:00

Here is an overview of my application: It is basically a cook book. The

  • 0

Here is an overview of my application:

It is basically a cook book. The user can create a cookbook and then create recipes within that cookbook. I have a class CookBook and a class Recipe. CookBook keeps track of what recipes are associated with the cook book and Recipe keeps track of the contents of the recipe.

For the UI, i have a treeview where it will display the recipes that are in the CookBook. I have a TabControl that will display the tabs associated with each recipe. The tabs are dynamically created by the user during run time.

When the user clicks on one of the recipes, i want the TabControl to show the tabs related to that specific recipe. When the user clicks on a different recipe i want the tabs for the previous selection to go away and the tabs of the current selection to appear. (side note: I will be saving the contents of the tab and stuff to a file later, for saving purposes)

I want the Recipe class to contain the details about the TabControl (how many tabs there are for the recipe, title of each of the tabs, contents of the tabs). But i do not want Recipe to be responsible for creating the Tabs or TabControl.

My questions is, how do i accomplish the bolded section above? What are people’s opinions and experience with this type of problem? What are the best practices for this type of problem?

THANKS!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:24:00+00:00Added an answer on May 23, 2026 at 11:24 pm

    I hope that the following code gives you an idea

    public Form1()
        {
            InitializeComponent();
    
            Recipe r1 = new Recipe() { Text = "Re1" };
            Recipe r2 = new Recipe() { Text = "Re2" };
            Recipe r3 = new Recipe() { Text = "Re3" };
    
    
            listBox1.Items.Add(r1);
            listBox1.Items.Add(r2);
            listBox1.Items.Add(r3);
    
    
            tabControl1.TabPages.Add(new AdvancedTabPage() { Recipe = r1,Text=r1.ToString() });
            tabControl1.TabPages.Add(new AdvancedTabPage() { Recipe = r2, Text = r2.ToString() });
            tabControl1.TabPages.Add(new AdvancedTabPage() { Recipe = r3, Text = r3.ToString() });
    
            listBox1.SelectedIndexChanged += new EventHandler(listBox1_SelectedIndexChanged);
    
        }
    
        void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem != null)
                foreach (AdvancedTabPage ad in tabControl1.TabPages)
                {
                    if (ad.Recipe == listBox1.SelectedItem)
                    {
                        tabControl1.SelectedTab = ad;
                        break;
                    }
                }
    
        }
    
        public class AdvancedTabPage : System.Windows.Forms.TabPage
        {
            public Recipe Recipe{get;set;}
    
    
        }
    
        public class Recipe
        {
            public string Text = "";
    
            public override string ToString()
            {
                return Text;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a problem with a WP7 app. I want that a user can
Overview: I have an application that sometimes must make something with celery- and if
brief overview so this is in context, I have an application in java that
Here is a quick overview of the controllers functionality in most of the application:
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
I am looking to find the most efficient way to create an application that
I have a small problem with an Xpage Application and hope that someone has
Here is a overview of my code. User press a record button and it
I can't update the view model. I have view called: Overview I have this
How can I make my C# app erase itself (self-destruct)? Here's two ways that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.