C# how can you add a tab in a tabcontrol but preset what the tab contains and any coding within that tab?
-
I am trying to add a tab to my tab control but I already want these to contain Textboxes that are linked to my database. Please can someone help
-
Answer:
You can't create new controls at runtime and be able to keep them there the next time the program is run. You will need to have the controls made at design time prior to the program being compiled/published. Instead of a tab control, consider using multiple forms.
Sam at Yahoo! Answers Visit the source
Other answers
There's a couple of ways you could save and re-create the tabs but I guess the simplest would be using Settings. Depending on what information you need to store to re-display the right data on each TabPage this might work: Assuming all you need to re-create the tabs is the database table name... Create a custom control which has the TextBox(s) you want to display. Depending on how you access your database in your application you want to modify the Constructor so it accepts either: 1. String - the name of the table the TextBox(s) should be linked to. or 2. The information already retrieved from the table. Whenever the "Add New" button is clicked: TabPage newPage = new TabPage(); newPage.Name = "newPage"; newPage.Text = "Tab text"; MyControl tabContent = new MyControl("table_name"); newPage.Controls.Add(tabContent); theTabControl.TabPages.Add(newPage); In your form's Closing event you'll want to loop over the tab pages and create a List of each one - storing the table name they link to. Then save that List as a Setting. When the application starts just load the List of table names and do the same as for "Add New"
Anthony
find what you like then go to file and hit new tab and duplicate it great way to go where you want theres no codeing
Russell
Related Q & A:
- How can I add a slideshow to my site?Best solution by webstarts.com
- How can I add a picture in my Signature for an outgoing mail?Best solution by Yahoo! Answers
- How can i add a sound to alert me of my incoming emails?Best solution by Yahoo! Answers
- How can I add a clickable link to a question or answer on yahoo?Best solution by Yahoo! Answers
- How can I add a picture to a video?Best solution by Answerbag.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.