English 中文(简体)
C#中两个组别箱涉及多个无线电台的计算
原标题:Calculations involving multiple radio buttons in two group boxes in C#

Hello I m 略微停留在涉及无线电台的任务上。 我正在使用另外一种说法......如果说要检查哪些无线电箱,那么我想根据从两个组别中选取哪些无线电纽子进行不同的计算。 在一组盒子中,有3种选择,即服装和价格,而在另一组箱中,有4种选择,即1-4。 当选择两个无线电台(每个组箱一个)时,我想进行计算。 我认为,我的发言是否正确,但是,如果很难进行计算和转换,只是用 t子进行计算,然后转换成内装或翻一番,并让他们参与计算。 由于我手法不使用这一表格的文字箱,因此:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Radio_Button_task
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    bool blnChecked = true;

    private void btnEnd_Click(object sender, EventArgs e)
    {
        this.Dispose();
    }

    private void btnClear_Click(object sender, EventArgs e)
    {
        lblTotal.Text = "";
        rbtnJeans.Checked = false;
        rbtnQuant1.Checked = false;
        rbtnQuant2.Checked = false;
        rbtnQuant3.Checked = false;
        rbtnQuant4.Checked = false;
        rbtnShirt.Checked = false;
        rbtnShorts.Checked = false;
    }

    private void btnCalculate_Click(object sender, EventArgs e)
    {
        double dbTotal;
        if (rbtnJeans.Checked && rbtnQuant1.Checked)
        {
            dbTotal = Convert.ToDouble(28 * 1);
        }
        else if (rbtnJeans.Checked && rbtnQuant2.Checked)
        {
            dbTotal = Convert.ToDouble(28 * 2);
        }
        else if (rbtnJeans.Checked && rbtnQuant3.Checked)
        {
            dbTotal = Convert.ToDouble(28 * 3);
        }
        else if (rbtnJeans.Checked && rbtnQuant4.Checked)
        {
            dbTotal = Convert.ToDouble(28 * 4);
        }
        lblTotal.Text = "The total cost is: £" + dbTotal.ToString("0.00");
    }
}
}
最佳回答

在没有收音机或只收听机的情况下,你没有处理过。 零开始使用b。

问题回答

如果说的话都是不实的话,问题就是所有的问题。 如果发生这种情况,你在最后使用<代码>dbTotal,而没有为此分配任何东西。 汇编者不喜欢。

简单明了的定式是,将<条码>db 当你创建时:

double dbTotal = 0;

可以做这样的事情。 还为项目选择提供类似的通道。 这里的“gbQuan”是所有广播邦的集团盒/频道。

private void btnCalculate_Click(object sender, EventArgs e)
{
double quan = 0, item = 28;
foreach (RadioButton temp in gbQuan.Controls)
{
    if (temp.Checked)
        quan = Convert.ToDouble(temp.Text);
}
lblTotal.Text = "The total cost is: £" + (item * quan).ToString("0.00");
}

希望会有所助益。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签