private void Sell_btn_Click(object sender, EventArgs e) { // get selected item value Stock stock = MyStocks_listView.SelectedItems.Count > 0 ? (Stock)MyStocks_listView.SelectedItems[0].Tag : null; if (stock == null) { return; } // to handle listView idiot 2 step item selection process // get the current price double askPrice = 0.0; for (int i = 0; i < StockMarket_listView.Items.Count; i++) { Stock s = (Stock)StockMarket_listView.Items[i].Tag; if (s.Company.Equals(stock.Company)) { askPrice = (double)s.AskPrice; break; } } // make the sell Console.WriteLine(stock.PurchasePrice + ", " + askPrice); DB_API.DeleteStockByTicker(account_id, (int)stock.Ticker, (double)stock.PurchasePrice, askPrice); // update MyStocks listView PopulateMyStocksListView(); }