Click here to Skip to main content
15,666,947 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I have a situation in which i wanted to create a Hotel Billing Application.Here when i click on the 'New Bill' button in the menu strip,a billing page opens.

I can open this page as many times i want,so i used tabcontrol here. Everytime i open this bill page,it takes the maximum value from database(from bill_no row) and increment by 1 and assign it to the tabitem content(the bill_no).

Whenever i click the 'New Bill' option, tabitem with same bill_no is displayed,its ok no problem with that.Let me explain it more deeply. I have clicked 'New bill' option 3 times and i have three tabitem with same content(bill_no) say 10.

Theres is save button bill page and if i am clicking on the save button in first tab, the details in that bill page will be saved in the database including bill_no, but still there are 2 tabitem with same content(bill_no,10).

Now when i click on the next tabitem, its content must be changed automatically to 11 beacause bill_no with 10 is already saved.

How can i achieve this?
Updated 31-Jul-12 4:49am
efkah 31-Jul-12 10:59am    
Just re-read your Question, is the bill_no only internal? why dont u use guids instead? its best practice anyways.
sabithp 31-Jul-12 11:25am    
what is guids?
efkah 31-Jul-12 11:34am
for reading into guid vs id as primary key try
sabithp 31-Jul-12 11:19am    
what is guids?

Add a Click EvenHandler that updates the tabitems when you create them.
Share this answer
sabithp 31-Jul-12 11:18am    
yes i did that,but when i go back to the first tabitem where i clicked the save button,that tabitem content is also updating.i dont want that.
Akinmade Bond 31-Jul-12 11:53am    
You can add a property that determines the tabitem that saved the information.
sabithp 31-Jul-12 12:13pm    
could you please tell me how to do that.actually i am a please
sabithp 2-Aug-12 7:18am    
should i use generics to do that?
please help me..
Are you using the MVVM design pattern? If you are not you should be. In the ViewModel, you should have the name of the tab or the information you want to use for the name and you can use a converter. The TabControl has a collection tabs, and you can bind the TabControl's ItemsSource to the collection of tabs you want displayed. See this blog: MVVM TabControl[^]. I know it is not a detailed example, but should be of help getting started with a properly designed Tab Control MVVM application.
Share this answer
sabithp 31-Jul-12 19:39pm    
oh i want to learn more about MVVM.could you please suggest me some tutorials to learn this.
thank you
Clifford Nelson 6-Aug-12 17:36pm    
Maybe this will help:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900