0

これを変換する方法を少し試してみました。これを Windows フォームでどのようにキャストしますか?

通常のコンソール アプリケーションのようには動作しないようです....

これがばかげているように見える場合は申し訳ありませんが、理解できません。

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 WindowsFormsApplication3
{
public partial class Form1 : Form
{
    float input1 = 0;
    float input2 = 0;
    float output = 0;

    int c = 0;


    public Form1()
    {
        InitializeComponent();

    }

    private void button10_Click(object sender, EventArgs e)
    {
        textBox1.AppendText("0");
    }

    private void button11_Click(object sender, EventArgs e)
    {
        textBox1.Clear();
    }

    private void button17_Click(object sender, EventArgs e)
    {

        textBox1 = output;
    }

    private void button12_Click(object sender, EventArgs e)
    {

         switch(c)
         {
             case '+': 
                 output = input1 + input2;

                 break;      
         }
    }
4

5 に答える 5

4
private void button17_Click(object sender, EventArgs e)
{

    textBox1.Text = output.ToString();
}

エラーが言っているtextBox1のは aであり、これを;TextBoxに変更しようとしています。Floatこれを行う方法の明確な方法はありません。

おそらく、あなたがやりたかったことは、テキストボックスのテキストをフロートの値に設定することでした。

于 2013-08-30T15:50:52.957 に答える
3
 textBox1.Text = output.ToString();
于 2013-08-30T15:50:41.880 に答える
2

Textプロパティに値を割り当てる必要があります。

textBox1.Text = output.ToString();
于 2013-08-30T15:50:51.220 に答える
2

これが問題です:

  private void button17_Click(object sender, EventArgs e)
    {

        textBox1 = output;
    }

何を達成したいですか?

多分:

  private void button17_Click(object sender, EventArgs e)
    {

        textBox1.Text = output.ToString();
    }
于 2013-08-30T15:51:11.830 に答える
2

に変更します

textBox1.Text = output.ToString();
于 2013-08-30T15:51:19.617 に答える