永发信息网

请帮忙如何在计算器编写程序中使用label控件

答案:1  悬赏:70  手机版
解决时间 2021-04-11 11:43
  • 提问者网友:川水往事
  • 2021-04-11 04:46

这是一个没有完成的计算器,

有如下程序,请问这些程序时什么意思,如何设置label控件

有三个label控件

// label1

//

this.label1.BackColor = System.Drawing.SystemColors.ControlDarkDark;

this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;

this.label1.Location = new System.Drawing.Point(12, 63);

this.label1.Name = "label1";

this.label1.Size = new System.Drawing.Size(39, 29);

this.label1.TabIndex = 1;

this.label1.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.label1_PreviewKeyDown);

//

// label2

//

this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;

this.label2.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));

this.label2.ForeColor = System.Drawing.Color.Red;

this.label2.Location = new System.Drawing.Point(14, 65);

this.label2.Name = "label2";

this.label2.Size = new System.Drawing.Size(37, 27);

this.label2.TabIndex = 1;

this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

this.label2.Click += new System.EventHandler(this.num_Click);

//

// label3

//

this.label3.AutoSize = true;

this.label3.Location = new System.Drawing.Point(12, 8);

this.label3.Name = "label3";

this.label3.Size = new System.Drawing.Size(0, 12);

this.label3.TabIndex = 0;

this.label3.Visible = false;

private void button_Enter(object sender, EventArgs e)

{

this.label1.Focus();

}

private void m_Click(object sender, EventArgs e)

{

Button button = (Button)sender;

if (button.Text == "MC")

{

mem = 0;

label2.Text = "";

}

if (button.Text == "MR")

{

textBox.Text = Convert.ToString(mem);

int temp = (int)mem;

double tm = (double)temp;

if (mem == tm)

textBox.AppendText(".");

compute = false;

}

if (button.Text == "MS")

{

mem = Convert.ToDouble(textBox.Text);

point = 0;

compute = false;

if(mem!=0)

label2.Text = "M";

}

if (button.Text == "M+")

{

mem = mem + Convert.ToDouble(textBox.Text);

}

}

private void label1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)

{

if (e.KeyCode == Keys.NumPad0)

num_Click(button23,e);

if (e.KeyCode == Keys.NumPad1)

num_Click(button18, e);

if (e.KeyCode == Keys.NumPad2)

num_Click(button19, e);

if (e.KeyCode == Keys.NumPad3)

num_Click(button20, e);

if (e.KeyCode == Keys.NumPad4)

num_Click(button13, e);

if (e.KeyCode == Keys.NumPad5)

num_Click(button14, e);

if (e.KeyCode == Keys.NumPad6)

num_Click(button15, e);

if (e.KeyCode == Keys.NumPad7)

num_Click(button8, e);

if (e.KeyCode == Keys.NumPad8)

num_Click(button9, e);

if (e.KeyCode == Keys.NumPad9)

num_Click(button10, e);

if (e.KeyCode == Keys.Subtract)

oper_Click(button21, e);

if (e.KeyCode == Keys.Add)

oper_Click(button26, e);

if (e.KeyCode == Keys.Multiply)

oper_Click(button16, e);

if (e.KeyCode == Keys.Divide)

oper_Click(button11, e);

if (e.KeyCode == Keys.Enter)

oper_Click(button27, e);

if (e.KeyCode == Keys.Decimal)

num_Click(button25, e);

}

}

}

最佳答案
  • 五星知识达人网友:老鼠爱大米
  • 2021-04-11 05:06
你好 楼主。
很幸运的看到你的问题。
但是又很遗憾到现在还没有人回答你的问题。也可能你现在已经在别的地方找到了答案,那就得恭喜你啦。
可能是你问的问题有些专业了,没人会。或者别人没有遇到或者接触过你的问题,所以帮不了你。建议你去问题的相关论坛去求助,那里的人通常比较多,也比较热心,可能能快点帮你解决问题。
希望我的回答也能够帮到你!
祝你好运。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯