0
ここに私のコードがあります。私はちょうど私の領収書のための新しいクラスを作成しました。 このコードは[追加]ボタン用です。Cのバインディングをリセットする#
else if (!string.IsNullOrEmpty(cmbProductName.Text) && !string.IsNullOrEmpty(txtQuantity.Text))
{
Receipt obj = new Receipt() { Id = order++, ProductName = Convert.ToString(cmbProductName.SelectedItem), Quantity = Convert.ToInt32(txtQuantity.Text), Price = Convert.ToDouble(txtPrice.Text) };
total += obj.Price * obj.Quantity;
receiptBindingSource.Add(obj);
receiptBindingSource.MoveLast();
Clear();
}
txtTotal.Text = String.Format("P{0}", Convert.ToString(total));
}
これは新しいデータの場合です。しかし、私が新しいをクリックすると、私は私のreceiptBindingSourceのデータをリフレッシュまたはリセットできません。合計金額は依然として計算を続ける。
private void New() {
cmbProductName.Text = string.Empty;
txtPrice.Text = string.Empty;
txtQuantity.Text = string.Empty;
txtCustomerName.Text = string.Empty;
txtCustomerNumber.Text = string.Empty;
txtTotal.Text = string.Empty;
txtCash.Text = string.Empty;
receiptBindingSource.Clear();
}
誰もが、私は新しいデータを追加カントので、私のreceiptBindingSourceをリフレッシュ、リセットする方法を私を助けることができます。新しいものを追加できるように、デバッグをやめる必要があります。私を助けてください。
どのようなコードを使用しますか?私を助けてくれますか? –
リセットのために作成したメソッドでは、totalの値を0に設定します。 – Sparrow
どうもありがとう!それは私のために働く:Dありがとう、ありがとう、ありがとう! –