简体   繁体   中英

display items in a windows form

What would be the best way to display items in c# in a form

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):

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?

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:

http://msdn.microsoft.com/en-us/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

您可以使用带有多列的列表框,此链接将帮助您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:

ListView, XPTable, ObjectListView, etc... it depends on specific requirements.

If you are asking more for best application design, the answer would be to implement MVP design pattern, or just to use data binding. 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. ObjectListView gives also advanced options, but as far as I know is not free. I don't recommend to use native .NET controls, since they aren't really customizable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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