WinForm+C#小案例--->用代码实现窗体设计的水果购物车小案例

C#WinForm案例(持续更新) 全选,反选,.两个ListBox中的内容左右相互移动,下拉框简易二级联动,简易2048,番茄钟,视频播放器 阅读详情
需求如下:
1. 能够进行单选或者多选
2. 需要展示购买的商品名称以及对应的商品数量
3. 展示购买的总价格
效果预览:
步骤 1:创建 Winform 项目并设计界面

步骤 2:编写代码实现切换逻辑
using System;
using System.Text;
using System.Windows.Forms;

namespace 水果购物车
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }
        //窗体加载事件
        private void Form1_Load(object sender, EventArgs e)
        {
            textBox1.Text = "0";
            textBox2.Text = "0";
            textBox3.Text = "0";
            textBox4.Text = "0";
            textBox5.Text = "0";
            textBox6.Text = "0";
            textBox7.Text = "0";
        }

        #region 按钮加减  
        //苹果减
        private void button1_Click(object sender, EventArgs e)
        {
            int count = int.Parse(textBox1.Text);
            if (count > 0)
            {
                count--;
                textBox1.Text = count.ToString();
                Shopping();
            }
        }
        //苹果加
        private void button2_Click(object sender, EventArgs e)
        {
            int count = int.Parse(textBox1.Text);
            count++;
            textBox1.Text = count.ToString();
            Shopping();

        }
        //香蕉减
        private void button4_Click(object sender, EventArgs e)
        {
            if (int.TryParse(textBox2.Text, out int count) && count > 0)
            {
                count--;
                textBox2.Text = count.ToString();
                Shopping();
            }
        }
        //香蕉加
        private void button3_Click(object sender, EventArgs e)
        {

            if (int.TryParse(textBox2.Text, out int count))
            {
                count++;
                textBox2.Text = count.ToString();
                Shopping();
            }
        }
        //橘子减
        private void button6_Click(object sender, EventArgs e)
        {
            if (int.TryParse(textBox3.Text, out int count) && count > 0)
            {
                count--;
                textBox3.Text = count.ToString();
                Shopping();
            }
        }
        //橘子加
        private void button5_Click(object sender, EventArgs e)
        {

            if (int.TryParse(textBox3.Text, out int count))
            {
                count++;
                textBox3.Text = count.ToString();
                Shopping();
            }
        }
        //草莓减
        private void button8_Click(object sender, EventArgs e)
        {

            if (int.TryParse(textBox4.Text, out int count))
            {
                count--;
                textBox4.Text = count.ToString();
                Shopping();
            }
        }
        //草莓加
        private void button7_Click(object sender, EventArgs e)
        {

            if (int.TryParse(textBox4.Text, out int count))
            {
                count++;
                textBox4.Text = count.ToString();
                Shopping();
            }
        }
        //西瓜减
        private void button10_Click(object sender, EventArgs e)
        {
            if (int.TryParse(textBox5.Text, out int count) && count > 0)
            {
                count--;
                textBox5.Text = count.ToString();
                Shopping();
            }
        }
        //西瓜加
        private void button9_Click(object sender, EventArgs e)
        {

            if (int.TryParse(textBox5.Text, out int count))
            {
                count++;
                textBox5.Text = count.ToString();
                Shopping();
            }

        }
        //芒果减
        private void button12_Click(object sender, EventArgs e)
        {
            if (int.TryParse(textBox6.Text, out int count) && count > 0)
            {
                count--;
                textBox6.Text = count.ToString();
                Shopping();
            }
        }
        //芒果加
        private void button11_Click(object sender, EventArgs e)
        {

            if (int.TryParse(textBox6.Text, out int count))
            {
                count++;
                textBox6.Text = count.ToString();
                Shopping();
            }
        }
        //火龙果减
        private void button14_Click(object sender, EventArgs e)
        {
            if (int.TryParse(textBox7.Text, out int count) && count > 0)
            {
                count--;
                textBox7.Text = count.ToString();
                Shopping();
            }
        }
        //火龙果加
        private void button13_Click(object sender, EventArgs e)
        {
            if (int.TryParse(textBox7.Text, out int count))
            {
                count++;
                textBox7.Text = count.ToString();
                Shopping();
            }
        }
        #endregion


        //全选
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            checkBox2.Checked = checkBox1.Checked;//苹果
            checkBox3.Checked = checkBox1.Checked;//香蕉
            checkBox4.Checked = checkBox1.Checked;//橘子
            checkBox5.Checked = checkBox1.Checked;//草莓
            checkBox6.Checked = checkBox1.Checked;//西瓜
            checkBox7.Checked = checkBox1.Checked;//芒果
            checkBox8.Checked = checkBox1.Checked;//火龙果
            Shopping();
        }


        #region 单个商品
        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            Shopping();
        }


        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            Shopping();
        }

        private void checkBox4_CheckedChanged(object sender, EventArgs e)
        {

            Shopping();
        }

        private void checkBox5_CheckedChanged(object sender, EventArgs e)
        {
            Shopping();
        }

        private void checkBox6_CheckedChanged(object sender, EventArgs e)
        {
            Shopping();
        }

        private void checkBox7_CheckedChanged(object sender, EventArgs e)
        {

            Shopping();
        }

        private void checkBox8_CheckedChanged(object sender, EventArgs e)
        {

            Shopping();
        }
        #endregion


        // 购物信息与总金额计算
        private void Shopping()
        {
            double totalPrice = 0;
            StringBuilder purchaseInfo = new StringBuilder("您购买了:\n");

            // 1. 苹果(checkBox2=苹果,textBox1=苹果数量)
            if (checkBox2.Checked && int.TryParse(textBox1.Text, out int appleCount) && appleCount > 0)
            {
                double appleTotal = 3.58 * appleCount;
                totalPrice += appleTotal;
                purchaseInfo.AppendLine($"苹果:{appleCount}份(500g/份) 单价:{3.58:F2}元 小计:{appleTotal:F2}元");
            }

            // 2. 香蕉(checkBox3=香蕉,textBox2=香蕉数量)
            if (checkBox3.Checked && int.TryParse(textBox2.Text, out int bananaCount) && bananaCount > 0)
            {
                double bananaTotal = 2.85 * bananaCount;
                totalPrice += bananaTotal;
                purchaseInfo.AppendLine($"香蕉:{bananaCount}份(500g/份) 单价:{2.85:F2}元 小计:{bananaTotal:F2}元");
            }

            // 3. 橘子(checkBox4=橘子,textBox3=橘子数量)
            if (checkBox4.Checked && int.TryParse(textBox3.Text, out int orangeCount) && orangeCount > 0)
            {
                double orangeTotal = 5.68 * orangeCount;
                totalPrice += orangeTotal;
                purchaseInfo.AppendLine($"橘子:{orangeCount}份(500g/份) 单价:{5.68:F2}元 小计:{orangeTotal:F2}元");
            }

            // 4. 草莓(checkBox5=草莓,textBox4=草莓数量)
            if (checkBox5.Checked && int.TryParse(textBox4.Text, out int strawberryCount) && strawberryCount > 0)
            {
                double strawberryTotal = 18.88 * strawberryCount;
                totalPrice += strawberryTotal;
                purchaseInfo.AppendLine($"草莓:{strawberryCount}份(500g/份) 单价:{18.88:F2}元 小计:{strawberryTotal:F2}元");
            }

            // 5. 西瓜(checkBox6=西瓜,textBox5=西瓜数量)
            if (checkBox6.Checked && int.TryParse(textBox5.Text, out int watermelonCount) && watermelonCount > 0)
            {
                double watermelonTotal = 1.99 * watermelonCount;
                totalPrice += watermelonTotal;
                purchaseInfo.AppendLine($"西瓜:{watermelonCount}份(500g/份) 单价:{1.99:F2}元 小计:{watermelonTotal:F2}元");
            }

            // 6. 芒果(checkBox7=芒果,textBox6=芒果数量)
            if (checkBox7.Checked && int.TryParse(textBox6.Text, out int mangoCount) && mangoCount > 0)
            {
                double mangoTotal = 7.88 * mangoCount;
                totalPrice += mangoTotal;
                purchaseInfo.AppendLine($"芒果:{mangoCount}份(500g/份) 单价:{7.88:F2}元 小计:{mangoTotal:F2}元");
            }

            // 7. 火龙果(checkBox8=火龙果,textBox7=火龙果数量)
            if (checkBox8.Checked && int.TryParse(textBox7.Text, out int pitayaCount) && pitayaCount > 0)
            {
                double pitayaTotal = 6.55 * pitayaCount;
                totalPrice += pitayaTotal;
                purchaseInfo.AppendLine($"火龙果:{pitayaCount}份(500g/份) 单价:{6.55:F2}元 小计:{pitayaTotal:F2}元");
            }

            // 处理无选中商品/无购买数量的情况
            if (purchaseInfo.ToString() == "您购买了:\n")
            {
                purchaseInfo.Clear();
                purchaseInfo.Append("您购买了:暂无商品");
            }

            label4.Text = purchaseInfo.ToString();
            label5.Text = $"总金额:{totalPrice:F2}元";
        }
    }
}
步骤3:效果演示

希望对大家有所帮助。感谢大家的关注和点赞。

C# WinForm 实例 WinForm 是 Windows Form 的简称,是基于 .NET Framework 平台的客户端(PC软件)开发技术,一般使用 C# 编程。C# WinForm 编程需要创建「Windows窗体应用程序」项目。 .NET 提供了大量 Windows 风格的控件和事件,我们可以直接拿来使用,上手简单,开发快速。 Windows 窗体应用程序是 C# 语言中的一个重要应用,也是 C# 语言最常见的应用。这套 C# WinForm 教程将教会大家如何使用 WinForm 进行界面设计,并绑定对应的事件,开 阅读详情

相关推荐

C# WinForm项目实战:198个源码实例解析

本文还有配套的精品资源,点击获取 简介:这是一套包含198个C# Windows Forms实例源代码的资源集合,专为C#开发者提供学习和参考。Windows Forms作为.NET Framework的一部分,用于构建具有丰富用户界面和事件处理的Windows桌面应用程序。这些实例涵盖了从基本控件使用到复杂事件处理的各种场景,适合初学者和经验丰富的开发者深入研究和实践。通...

weixin_36184718的博客 4954

WinForm应用实战开发指南 —— 一些综合案例Demo

本文为大家介绍在WinForm开发框架中的一些综合案例Demo,希望能帮助到大家~

需要界面开发、IDE工具研发中文教程资料的小伙伴,记得私信我~ 2415

C# WinForm窗体设计高级技巧与实例

C# WinForm 是 .NET 框架下用于开发图形用户界面应用程序的一种方式。它允许开发者使用可视化的设计工具以及代码来创建桌面应用程序。WinForm 提供了丰富的控件库,使得设计出符合用户习惯的界面变得简单快捷。在实现自定义控件的拖放时,首先需要创建一个支持拖放操作的自定义控件类。这个类应当继承自Control类,并实现相关的拖放接口和事件。// 构造函数和其他基本控件设置代码...// 重写OnMouseDown等方法来处理拖放逻辑// 调用基类的OnMouseDown方法。

weixin_35749796的博客 1981

## C# winform DataGridView 实现的购物车

C# winform界面实现的购物车,能根据所选的数据,实时算出工资和数量

qq_40823894的博客 1768

neruolib全脑建模计算框架

neurolib 是一个用python编写的全脑建模计算框架,也是可扩展的、允许轻松实现自定义神经质量模型,能够在介观尺度上表示脑区平均活动。

Rootfyx的博客 1148

SDU CS 期末考回忆版合集

删除原有分散的版本,合订起来画个。包括:机器学习、算法、图形学、操作系统、编译原理、软件工程、大数据分析管理、计算机体系结构等。

https://github.com/ZhaoyungZhang 6649

ajax 购物车 c#,c#购物车功能实现及收藏功能实现

一.思路逻辑:首先我先来说一下我自己的理解,一个萌新的见解,要实现购物车的功能,首先要获取到登录时的用户id及商品的编号(商品id),这里我用的模式是mvc模式进行实现功能的,用户登录时,利用session保存用户的登录用户名,然后在控制器里进行传值操作,定义一个session进行接收用户输入的用户名,登录成功后进行保存用户的用户名,登录成功,前台在进行跳转到显示界面,点击事先创建好的购物车按钮,...

weixin_42517854的博客 628

告别反复格式化!用Ventoy制作2025年终极启动盘,Windows/Linux/macOS一网打尽

本文详细介绍了如何使用Ventoy制作2025年终极多系统启动盘,彻底告别反复格式化U盘的烦恼。Ventoy通过创新的引导加载器架构,允许用户在一个U盘内同时存放并直接启动Windows、Linux、macOS等多种系统镜像和WePE等维护工具,实现真正的非破坏性管理和极高的U盘利用率。文章涵盖从安装配置、镜像库构建到安全启动设置等全流程实战指南。

weixin_29280219的博客 242

Winform开发小例

1. 理解“Windows 窗体应用程序”项目中Program.cs文件中的main方法与传统C++Console控制台程序中的main方法的区别。从程序运行层次上讲,两者无区别,都是程序的入口点,属于进程中的第一个线程。前者隐藏了UI应用程序必需的消息循环,后者没有。 2. 每个Windows桌面应用程序都必须包含至少一个UI线程,所谓UI线程,就是可以响应Windows消息的线程。通常情...

那一抹、璀璨 2855

从零构建虚幻引擎体积云:参数调优与性能平衡的艺术

本文深入探讨了在虚幻引擎中构建逼真体积云系统的关键技术,包括Sky Atmosphere、Volumetric Cloud和Exponential Height Fog三大核心组件的协同工作。重点解析了体积云材质的高级控制、光照阴影的物理模拟以及性能优化策略,帮助开发者在视觉效果与性能之间找到最佳平衡点。

weixin_29012677的博客 938

生物量预测:基于Swin-Unet模型的生物量模型预测

本文提出了一种基于Swin-Unet架构的多源遥感地上生物量(AGB)预测方法。该方法整合了光学影像、SAR雷达影像、气候环境参数以及地形数据(坡度和坡向)等多源信息,通过24个输入通道(13+2+7+1+1)构建预测模型。研究采用Min-Max归一化预处理数据,并使用80%训练集、16%验证集和20%测试集的划分策略。模型基于Swin-Unet 2D架构,设置64个初始滤波器、4层深度、4×4堆叠数和2×2补丁大小。该方法通过整合多源遥感数据和先进深度学习架构,为AGB反演提供了新的解决方案。

此星光明博客 62

WinForm+C#小案例--->情侣版抽奖小游戏

【代码】WinForm+C#小案例--->情侣版抽奖小游戏。

MM_MS的博客 534

国科大学习资料--高级软件工程-复习题概念解释答案

国科大学习资料–高级软件工程(罗铁坚 魏峻 刘丹)-复习题概念解释答案 1. 敏捷开发方法与Scrum方法 a.敏捷是一种强调轻量的过程方法论,它强调拥抱变化而不是与之对抗,通过有效的沟通发挥群体的智慧。敏捷方法采用迭代/增量开发的过程模型。敏捷宣言是:个体和交互高于流程和工具;工作的软件高于详尽的文档;客户合作高于合同谈判;响应变化高于遵循计划。 虽然右边的也有价值,但是认为左边的更有价值。 b.Scrum(Schwaber和Beedle)是管理两个披萨规模(4-9人)的软件开发团队的方法,它高频率的短会

无名何许人的博客 1444

C#多线程基础

最近自己写了个小爬虫,里面用到了多线程技术,忽然发现对此技术竟然有些陌生了,于是乎开始疯狂的去问度娘,在此记录下来,以便自己和各位小伙伴们学习。 一、什么是线程 一个应用程序就相当于一个进程,进程拥有应用程序的所有资源进程包括线程,进程的资源被线程共享,但不拥有线程。我们可以打开电脑中的任务管理器,运行的.exe都是一个进程,里面的分支是线程。 二、多线程 多线程其实就是进程中一...

weixin_30700977的博客 414

如何选择深度强化学习算法:MuZero/SAC/PPO/TD3/DDPG/DQN/等算法

如何选择深度强化学习算法:MuZero/SAC/PPO/TD3/DDPG/DQN/等算法

丨汀、的博客 5222

让 ABAP 开发者也能做出高质量 SAP Fiori:到底需要掌握多少前端知识?

文章摘要: 随着SAP技术演进,ABAP开发者的角色边界正在重构。传统SAP GUI时代的全栈开发模式逐渐转向RAP+Fiori Elements的新范式,其中关键技术变化包括: 开发模式转变:从前后端耦合转向RAP模型驱动开发,通过CDS注解实现UI意图表达 分工优化:Fiori Elements模板处理80%标准UI需求,Flexible Programming Model解决20%差异化需求 效率提升:注解驱动开发可在RAP建模阶段同步定义UI结构,大幅缩短交付周期 工具整合:SAP提供从建模到部署的

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 350

C# WinForm开发系列 - Form/Window

Form是WinForm开发中非常重要的一个控件, 本文将包含如何制作一个关于对话框,系统载入提示窗体, 创建类似于QQ提示框以及创建不规则窗体等(文章及相关代码搜集自网络,仅供学习参考,版权属于原作者! ).   1.愚翁专栏   优快云第一期总结之一:Form问题Form问题是最基本的问题,因为编写WinApp程序首先接触的对象就是它,因此在论坛中对它而产生的问题也最常见。与Fo

探索者的专栏 3211

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

C#写购物车

这个主要用Session跟Hashtable,前面的就不写了,using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.

yn098的专栏 2569

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

C#用户自定义控件(创建及引用)购物加入购物车

C#用户自定义控件(创建及引用)1.准备工作2.编辑控件3.引用所定义的控件 1.准备工作 首先我们打开vs(我这里使用vs 2019),创建一个 Windows窗体控件 的项目。 创建项目名为 Mycj 的自定义窗体控件。 2.编辑控件 创建控件之后我们点击创建好的控件,更改合适的 大小 以及控件的 Name 属性(这里我的为Order),并在 工具箱 中拖自己想要的控件(这里我以类似淘宝的...

qq_28996795的博客 3182

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

Winform高级技巧-界面和代码分离的实践案例

活到老就该学到老。但是难道我们不可以偷懒么,老技术指哪打哪,游刃有余,如果已经炉火纯青,那么解决问题又快又好它不香吗。本文拒绝讨论技术谁优秀谁该被鄙视。上图的流程是花2天时间搞好的,我不是得瑟有什么不得了的地方。我见很多人都在探讨MVVM,数据驱动业务多么的了不起,其实老技术Winform一样的能办到不信你问问DeepSeek让它给你一个示例代码。比如这样子的,点这里下载。如果只是这么简单的话,就没有写本文的必要了。我们看看上图的场景,因为现场的实际方案没有最终确定,所以开发人员写了5个版本的代码来验证5种

xdpcxq的专栏 1126

C# 登录功能(优雅且详细)

1. 制作一个登陆界面,包含验证码,记住密码以及根据登录用户类型(RoleID)加载不同界面的功能。 2. 用户使用账号与密码登录系统。本系统的用户包括 3 种类型 3. 若用户的登录失败次数达到 3 次,那么系统应显示并且同时包含字母与数字的4位验证码,验证码字符输入正确方可登录。 4. 若选择记住密码,下次登录时直接显示上次输入的账号和密码

这里是努力做好AC吧 1万+

Winform综合实例(常用控件使用及项目实例)

Winform综合实例(常用控件使用及项目实例)

lvxingzhe3的博客 982

Winform实战(模仿篇)

(新增用户控件->画笔Paint自己画->工具箱可自动加载该组件->大组件套小组件随便用)

qq_36826498的博客 1016

c#购物车功能实现,用户登录及收藏功能实现

一.思路逻辑: 首先我先来说一下我自己的理解,一个萌新的见解,要实现购物车的功能,首先要获取到登录时的用户id及商品的vb.net教程编号(商品id),这里我用的模式是mvc模式进行实现功能的,用户登录时,利用session保存用户的登录用户名,然后在控制器里进行传值操作,定义一个session进行接收用户输入的用户名,登录成功后进行保存用户的用户名,登录成功,前台在进行跳转到显示界面,点击事先创建好的购物车按钮,把我们已经保存好的用户名传过去,在c#教程进行session接收用户名字,添加到购物车时,前面

chinaherolts2008的博客 2844

198个经典C#WinForm实例源码

目录 1、窗体技巧 2、控件操作 3、图像操作 4、报表打印 5、系统操作 6、文件处理 7、网络操作 8、数据库操作 9、加密和解密 10、硬件读写 1、窗体技巧 链接:https://pan.baidu.com/s/1825O8o-8lumNyp1okp9x5g 提取码:v77o 2、控件操作 链接:https://pan.baidu.com/s/1w2BSd3AQRxa77O4h9F6R9A 提取码:0b6o 3、图像操作 链接:https:......

panjinliang066333的博客 1万+

winform分页案例简单实现方式~

大家好,我是雄雄,欢迎关注微信公众号:雄雄的小课堂。最近,四班在做KTV点歌系统,正好需要用到分页的内容,所以今天我就整理整理,写了一个简易的winfrom分页案例,以下是案例截图:案例分...

穆雄雄的博客 2021
上一篇: WinForm+C#小案例--->写一个音乐播放器
下一篇: MySQL超详细安装及基本使用教程
MM_MS
博客等级 码龄1年 58粉丝 100原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MM_MS

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值