Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

What I need to display is the customer name from the custCollection XML file and tickerSymbol, quantity, and price from the stocklist XML file. I cannot figure out what code to insert to display the correct data from each XML file. Could anyone please help.

public partial class Customer_Stock_Information_Form : Form
{
    StockCollection stkCollection;
    CustomerCollection custCollection;

    public string custName; //field from customer class 
    public string tickerSymbol; //field from the stock class
    public int quantity; //field from the stock class 
    public double currentPrice; //field from the stock 

    public Customer_Stock_Information_Form(StockCollection scPassed, CustomerCollection ccPassed)
    {
        stkCollection = scPassed;
        custCollection = ccPassed;
        InitializeComponent();
    }

    //public Customer_Stock_Information_Form(string custName, string tickerSymbol, int quantity, double currentPrice)
    //{
    //    this.custName = custName;
    //    this.tickerSymbol = tickerSymbol;
    //    this.quantity = quantity;
    //    this.currentPrice = currentPrice;
    //}

    //when this form is loaded, add the customer ID's from each customer into the comboBox..**THIS WORKS**
    private void Customer_Stock_Information_Form_Load(object sender, EventArgs e)
    {            
        for (int i = 0; i < custCollection.Count; i++)
            cboID.Items.Add(custCollection[i].Id);           
    }

    ////////once  a customer ID is selected, display information for that individual in display window..**THIS IS NOT WORKING PROPERLY** **What do I need here????**
    private void cboID_SelectedIndexChanged(string custName, string tickerSymbol, int quantity, double currentPrice)//(object sender, EventArgs e)                           
    {
        for (int i = 0; i < custCollection[cboID.SelectedIndex].Stocklist.Count; i++)//select customer id from cbo Box
            lstCustInfo.Items.Add(custCollection[cboID.SelectedIndex].Stocklist[i]); //display the chosen customer data. THIS IS ONLY SHOWING TICKER chosen in the customer form
            //lstCustInfo.Items.Add(custName, tickerSymbol, quantity, currentPrice);  
            //lstCustInfo.Items.Add(stkCollection(tickerSymbol, quantity,currentPrice));
    }

    // display customer name, ticker symbol, quantity, and price...THIS IS NOT DISPLAYING ANY DATA
    public override string ToString()
    {
        return 
        "Name: " + Name + "  " + "Ticker: " + tickerSymbol + "   " + "Quantity: " + quantity + "  " + "Price: " + currentPrice.ToString("C");
    }

    private void btnExit_Click(object sender, EventArgs e)
    {
        this.Close();
    }
share|improve this question

closed as off topic by Michael K May 1 '12 at 19:48

Questions on Code Review Stack Exchange are expected to relate to code review request within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.

3  
How is your code not working? What does it do? Could you explain what exactly is it supposed to do? –  svick Apr 30 '12 at 17:26
    
the listbox is supposed to display the customer name from the customerList and display the tickerSymbol, quantity, and price from the stockList on a single row or however. At this point I just want it to display the proper data. When the form loads it loads the customer ID into a combobox and when the Id number is selected it is to display the data mentioned in the display. Hope that helps –  Randy Apr 30 '12 at 18:06
    
It is not displaying the correct data. I need to display the customer name from the customerList XML file and the tickerSymbol, quantity, and price from the stockList XML file in the listbox which resides in the Customer_Stock_Information_Form . –  Randy Apr 30 '12 at 18:28

1 Answer 1

  • You are overriding the ToString() of the form itself.
  • You should clear the list in case the selected index has changed (as you add new items)
  • The list control. Is it a listBox or a listView? In the case of a listBox, the item you put in should override the ToString. Otherwise, add multiple columns and sub items.
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.