简体   繁体   English

以Windows形式显示项目

[英]display items in a windows form

What would be the best way to display items in c# in a form 在表单中以c#显示项目的最佳方法是什么

For example I have a pizza(small,medium,large) button. 例如,我有一个披萨(小,中,大)按钮。

If I press the small pizza button it will display like this: 如果我按下比萨饼的小按钮,它将显示如下:

Order:
Item          Quantity    Price
Small Pizza   1           3.99

If I press the add pepperoni button it will display like this: 如果按添加意大利辣香肠按钮,它将显示如下:

Order:
Item          Quantity    Price
Small Pizza   1           3.99
-Pepperoni    1           0.99

If I press the add pepperoni button it will display like this(making it double pep): 如果我按添加意大利辣香肠按钮,它将显示如下(使其变为两次pep):

Order:
Item          Quantity    Price
Small Pizza   1           3.99
-Pepperoni    2           1.98

Also adding another item such as a large pizza it will display like this: 同时添加另一个项目,例如大比萨饼,它将显示如下:

Order:
Item          Quantity    Price
Small Pizza   1           3.99
-Pepperoni    2           1.98
Large Pizza   1           6.99

I basically just want it so you can see what you've added to the order. 我基本上只想要它,这样您就可以看到您添加到订单中的内容。

What would be the best way to do this with c# and windows form? 用C#和Windows Form做到这一点的最佳方法是什么?

For a general look at some of the tools available for developing c# applications focused on winforms I'd point you to the MSDN How Tos: 大致了解一些可用于开发针对winforms的c#应用程序的工具,我将向您介绍MSDN How Tos:

http://msdn.microsoft.com/en-us/vstudio/bb798022#winforms http://msdn.microsoft.com/zh-CN/vstudio/bb798022#winforms

There are some specific for list controls which others have mentioned, and several provide examples of how to hook up button press events to performing user interface actions. 有一些特定的列表控件,其他的已经提到,还有一些提供了如何将按钮按下事件与执行用户界面操作挂钩的示例。

I would also advise the use of databinding in place of "manually" setting/retrieving values. 我还建议使用数据绑定代替“手动”设置/检索值。

WinForms Databinding WinForms数据绑定

您可以使用带有多列的列表框,此链接将帮助您http://www.codeproject.com/KB/combobox/multicolumnlistbox.aspx

There is no simple answer since the question is not well formed in my opinion. 没有简单的答案,因为我认为该问题的格式不正确。

If you are asking for specific GUI control, I will answer: 如果您要求特定的GUI控件,我将回答:

ListView, XPTable, ObjectListView, etc... it depends on specific requirements. ListView,XPTable,ObjectListView等...取决于特定要求。

If you are asking more for best application design, the answer would be to implement MVP design pattern, or just to use data binding. 如果您对最佳应用程序设计有更多要求,答案将是实现MVP设计模式,或者仅使用数据绑定。 It is really hard to suggest anything more specific, since question doesn't describe any specific use case. 很难提出更具体的建议,因为问题并未描述任何具体的用例。

Edit: So for lists the XPTable control (http://www.codeproject.com/KB/list/XPTable.aspx - and updated version on sourceforge) should be OK. 编辑:因此对于列表XPTable控件(http://www.codeproject.com/KB/list/XPTable.aspx-以及sourceforge上的更新版本)应该可以。 ObjectListView gives also advanced options, but as far as I know is not free. ObjectListView还提供了高级选项,但据我所知并不是免费的。 I don't recommend to use native .NET controls, since they aren't really customizable. 我不建议使用本机.NET控件,因为它们并不是真正可定制的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM