So basically I need to create a short program that will allow the user to select "x" "y" and "z" with quanity. I know how I want the program to look "visually" but sadly I am lacking some of the elements required. I also want it to loop incase the "user" decides they want to add something else before checking out, I am also going to have it verify the order.

I will be using a Windows Form Application to make this program.

First I'd like to see if it'll be easier for me to just do a Console Application vs Windows Form App.

I will add that this will be my first project with C#, I will apologize now for the amount of questions I will ask, please note I am not asking anyone to do my work for me.

Secondly, are Checkboxes my best bet with a numericUpDown going to be my best feature? "Note" Should I place the price amount of each item in with its checkbox, or should I use a lable?

Dani AI

Generated

For and anyone building a small purchase app: start by separating business logic (products, cart, totals) from the UI. Prototyping the logic in a Console app makes the core behavior easy to test (add/remove, merge quantities, compute totals) without wrestling with events. After the logic works, implement a WinForms front end that calls those classes. WinForms is event-driven, so the UX will be driven by button clicks and control events rather than an explicit loop.

's listbox idea is a perfectly fine, simple UI. Practical pattern: keep a catalog bound to a data list (ListBox or DataGridView) that shows name and price, use a NumericUpDown for quantity, and an Add button that adds/merges an item into a cart collection displayed in a second ListBox or DataGridView. Checkboxes work if quantity is always 1, but if per-item quantity is required the list+qty+add-button flow is cleaner. Put the price in the display for readability, but keep the authoritative price in the Product object (do not parse UI text to do calculations).

Example model classes:

class Product {
  public string Name { get; set; }
  public decimal Price { get; set; }
  public override string ToString() => $"{Name} - {Price:C}";
}

class CartItem {
  public Product Product { get; set; }
  public int Quantity { get; set; }
  public decimal Total => Product.Price * Quantity;
}

Example add-to-cart logic (bound lists assumed):

var p = (Product)listBoxCatalog.SelectedItem;
int qty = (int)numericUpDownQty.Value;
var existing = cart.FirstOrDefault(ci => ci.Product == p);
if (existing != null) existing.Quantity += qty;
else cart.Add(new CartItem { Product = p, Quantity = qty });
labelTotal.Text = cart.Sum(ci => ci.Total).ToString("C");

Practical tips: use decimal for money, not double; format totals with ToString("C"); set numericUpDown.Minimum = 1 and DecimalPlaces = 0 for integer quantities; merge duplicates instead of creating separate entries; use BindingList<T> or BindingSource so the UI updates automatically; implement a modal "Review Order" dialog for verification/checkout. Avoid putting calculation logic into UI event handlers—keep it in testable classes.

Recommended Answers

All 2 Replies

Put your xyz items, together with a price in a listbox. Create a second listbox with the choices, your puchases. Here is a short tutorial about listboxes.

, thanks for the response, I'm aboutto have a look at that link you provided.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.