messi661 2021-04-19 22:18 采纳率: 0%
浏览 37

c#新手求助,窗体不能显示

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

namespace WindowsFormsApp5
{
    public partial class Form1 : Form
    {
        private int nCounter;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.nCounter = 50;
            this.ShowCounter();
        }

        private void btnInc_Click(object sender, EventArgs e)
        {
            this.nCounter++;
            this.ShowCounter();
        }

        private void btnDes_Click(object sender, EventArgs e)
        {
            this.nCounter--;
            this.ShowCounter();
        }

        private void btnMsg_Click(object sender, EventArgs e)
        {
            string strMsg = "当前计数器=" + this.nCounter.ToString("D8");
            MessageBox.Show(strMsg, "提示");
        }
        private void ShowCounter()
        {
            string strMsg = "当前计数器=" + this.nCounter.ToString("D8");
            this.lblResult.Text = strMsg;
        }
    }

照着书敲的代码,为什么不显示窗体

  • 写回答

1条回答 默认 最新

  • 久绊A 全栈领域新星创作者 2023-01-22 17:56
    关注
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
     
    namespace WindowsFormsApp5
    {
        public partial class Form1 : Form
        {
            private int nCounter;
            public Form1()
            {
                InitializeComponent();
            }
     
            private void Form1_Load(object sender, EventArgs e)
            {
                this.nCounter = 50;
                this.ShowCounter();
            }
     
            private void btnInc_Click(object sender, EventArgs e)
            {
                this.nCounter++;
                this.ShowCounter();
            }
     
            private void btnDes_Click(object sender, EventArgs e)
            {
                this.nCounter--;
                this.ShowCounter();
            }
     
            private void btnMsg_Click(object sender, EventArgs e)
            {
                string strMsg = "当前计数器=" + this.nCounter.ToString("D8");
                MessageBox.Show(strMsg, "提示");
            }
            private void ShowCounter()
            {
                string strMsg = "当前计数器=" + this.nCounter.ToString("D8");
                this.lblResult.Text = strMsg;
            }
        }
    
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度