我有一個winform,有很少的組合框,texboxes等等...所以我想通過點擊btnAdd從txtTotal中的txtStake乘以值,但每次當我單擊btnAdd時,我也想要乘以結果。執行乘法,文本框
//For example:
//click-1, txtStake = 2, txtTotal = 2;
//click-2, txtStake = 2, txtTotal = 4;
//click-3, txtStake = 3, txtTotal = 12;
//click-3, txtStake = 4.5 txtTotal = 54; Ok? How to do that? Thanks.
--------------------------------------------------------------------
class Multy
{
public decimal Stake;
public Multy()
{}
}
private List<Multy> matches = new List<Multy>();
private void btnAdd_Click(object sender, EventArgs e)
{
matches = new List<Multy>();
Multy match = new Multy();
match.Stake = decimal.Parse(txtStake.Text);
matches.Add(match);
decimal l_Stake;
string strStake;
string strOutputLine;
foreach (Multy m in matches)
{
l_Stake = m.Stake;
strStake = l_Stake.ToString();
}
txtTotal.text = //code?
}
您正在創建一個新的(空)'matches'的每次點擊列表。這可能不是你想要的。 –