C#WPF中的编号表 [英] Numbering tabitem in c# WPF

查看:219
本文介绍了C#WPF中的编号表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一种情况,我想创建一个酒店计费应用程序.在这里,当我单击菜单栏中的新账单"按钮时,会打开一个计费页面.

我可以多次打开此页面,因此我在这里使用了tabcontrol.每次我打开此账单页面时,它都会从数据库(从bill_no行)获取最大值,并递增1并将其分配给tabitem内容(the bill_no).

每当我单击新帐单"选项时,都会显示具有相同bill_no的tabitem,这没关系.让我更深入地解释一下.我单击了新账单"选项3次,并且我有三个具有相同内容的tabitem(bill_no)说10.

有一个保存按钮帐单页面,如果我单击第一个选项卡中的保存按钮,该帐单页面中的详细信息将保存在数据库中,其中包括bill_no,但仍然有2个具有相同内容的tabitem(bill_no,10). br/>
现在,当我单击下一个tabitem时,其内容必须自动更改为11,因为bill_no和10已被保存.

我该如何实现?

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?

推荐答案

添加一个Click EvenHandler,在创建它们时会更新这些Tabitem.
Add a Click EvenHandler that updates the tabitems when you create them.


您正在使用吗? MVVM设计模式?如果不是,那应该是.在ViewModel中,您应该具有选项卡的名称或要用于名称的信息,并且可以使用转换器. TabControl具有集合选项卡,您可以将TabControl的ItemsSource绑定到要显示的选项卡的集合.观看此博客: MVVM TabControl [
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.


这篇关于C#WPF中的编号表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆