1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to delete a selected item from a row?

Discussion in 'C#' started by highthe, Nov 24, 2011.

  1. highthe

    highthe New Member

    Joined:
    Nov 24, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    DialogResult result3 = MessageBox.Show("Proceed With Checkout?", "Request Granted",
    MessageBoxButtons.YesNo,
    MessageBoxIcon.Question,
    MessageBoxDefaultButton.Button2);
    
                if (result3 == DialogResult.Yes)
                {
                    int quantity = Int32.Parse(quantityTextBox.Text);
                    if (quantity ==1)
                    {
                        this.BindingContext[iTEMDataSet, "ITEM"].RemoveAt(this.BindingContext[iTEMDataSet, "ITEM"].Position);
                    }
                    else if (quantity > 1)
                    {
                        quantity = quantity - 1;
                        quantityTextBox.Text = Convert.ToString(quantity);
                        //update database here.
                    }
    
                }
                if (result3 == DialogResult.No)
                {
                    //quantity = quantity - 1;
                    //quantityTextBox.Text = Convert.ToString(quantity);
                }
            }
            catch
            {
                MessageBox.Show("error!");
            }
        }
    
    //As you can see this program allows you to deleted the quantity of an item in a row , but if the quantity = 1 , the item in the top most row will be deleted instead of the selected row.

    I changed 'RemoveAt(this.BindingContext[iTEMDataSet, "ITEM"].Position); but to no avail .

    Thanks for the help guys ^^
     

Share This Page