当前位置: 首页 > news >正文

郑州门户网站制作链接优化方法

郑州门户网站制作,链接优化方法,h5游戏在线玩,吴江建设局网站打不开一、winform项目与窗体控件 1、部分类的使用 好处:让自动生成的代码后置,我们编写程序的代码显得更加简洁 特点:在最后编译的时候,仍然编译成一个窗体类。 窗体和控件的基本使用 3、Event事件(委托--》事件&#…

一、winform项目与窗体控件

1、部分类的使用

好处:让自动生成的代码后置,我们编写程序的代码显得更加简洁

特点:在最后编译的时候,仍然编译成一个窗体类。

  1. 窗体和控件的基本使用

3、Event事件(委托--》事件)

理解事件:

在.Net平台上面,给我们所用的这些控件,封装了很多的事件。所谓事件,就是对用户操作的某一个行为进行封装。比如,当用户点击一个按钮的时候,单击这个动作,已经被封装成了Click事件,那么我们只要把这个事件拿出来,当用户触发单击这个动作的时候,也就是这个事件被调用了,我们就可以在这个事件中,完成我们需要的任务。

InitializeComponent();//调用Desinger类中的方法,用于控件初始化

Sender表示当前控件的对象

二、学会:

【1】能够找到我们需要的控件事件。

【2】根据事件生成事件方法,并编写业务逻辑。

【3】如果事件不在需要,要知道如何把事件关联(委托)和事件方法的删除,如果址删除一个事件方法会报错。

【4】窗体的俩个事件,并且学会窗体关闭前的确认逻辑是如何处理的!

事件参数:

        //窗体关闭后发生的private void Form1_FormClosed(object sender, FormClosedEventArgs e){//可以在这里编写要做的其他任务// MessageBox.Show("窗体关闭了","",MessageBoxButtons.OK);}

核心内容:窗体常用属性、按钮常用属性、按钮单击事件、生成方法、事件删除方法、窗体常用事件和退出确认的实现。

  1. 事件的集中响应

原理:就是相同的控件、可以关联同一事件响应方法

好处:可以集中处理数据

核心内容:按钮的集中添加和Tag数据的封装、窗体Controls集合优化事件关联。

  1. 事件通用处理中数据的获取

核心内容:在按钮事件中获取数据的方法、对象的封装、泛型集合List运用

三、控件或窗体右键属性

c# ContextMenuStrip控件简单用法-CSDN博客

C# Winform MessageBox的用法 各种类型弹出框-CSDN博客

winform窗体关闭事件的实例-CSDN博客

  • 事件的集中响应

复制(Ctrl+拖动)控件时它的事件也会复制

原理:相同的控件,可以关联同一个事件响应方法

好处:我们可以集中处理数据

容器控件(Panel等...):

在容器中放控件必须加到对应的容器的集合(Controls)里面

代码实例:

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 client_sideUI
{public partial class Form1 : Form{private List<string> Clacklist = new List<string>();//数据绑定控件private BindingSource bindingSource = null;/// <summary>/// 构造方法:初始化所有的控件/// </summary>public Form1(){//this.button1.Text = "111";//在初始化的方法前面不要写任何代码InitializeComponent();//调用Desinger类中的方法,用于控件初始化//将控件的Click事件和事件方法关联this.button1.Click += new System.EventHandler(this.buttonNoe_Click);//我们想完成控件或其他初始化内容,在构造方法中写!SetupDataBinding();}// 设置数据绑定private void SetupDataBinding(){bindingSource = new BindingSource();// 使用匿名类型转换字符串列表var bindingList = Clacklist.Select(s => new { 课程名称 = s }).ToList();bindingSource.DataSource = bindingList;dataGridView1.DataSource = bindingSource;}// 刷新DataGridView显示private void RefreshGridView(){SetupDataBinding();//刷新数据bindingSource.ResetBindings(false);//重新加载数据dataGridView1.Refresh();}//事件方法private void button1_Click(object sender, EventArgs e){}//事件方法private void buttonNoe_Click(object sender, EventArgs e){//sender表示当前控件的对象//Button btn = sender as Button;Button btn = (Button)sender;MessageBox.Show("btnclick");//选中单选框this.checkBox1.Checked = true;//我们也可以动态的取消事件的关联//this.button1.Click -= new System.EventHandler(this.buttonNoe_Click);}//窗体所有控件和初始化完毕后要执行的事件,我们通常不用private void Form1_Load(object sender, EventArgs e){//不建议在这里写初始化内容}//窗体关闭之前发生的private void Form1_FormClosing(object sender, FormClosingEventArgs e){if ((MessageBox.Show("确定关闭吗", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)){e.Cancel = false;}else{//不关闭窗体e.Cancel = true;}}//窗体关闭后发生的private void Form1_FormClosed(object sender, FormClosedEventArgs e){// MessageBox.Show("窗体关闭了","",MessageBoxButtons.OK);}//private void button1_MouseEnter(object sender, EventArgs e)//{//    Button btn = sender as Button;//    //tag属性可以随便写值//    btn.Tag = "btn1";//    MessageBox.Show(btn.Tag.ToString());//}//关闭窗体private void button2_Click(object sender, EventArgs e){this.Close();}private void label1_Click(object sender, EventArgs e){Label label = (Label)sender;label.Text = "1";}private void button3_6_Click(object sender, EventArgs e){Button button = (Button)sender;Clacklist.Add(button.Tag.ToString());//bindingSource.DataSource = Clacklist;MessageBox.Show($"{Clacklist[0].ToString()}");RefreshGridView();}private void button7_Click(object sender, EventArgs e){Clacklist.Clear();RefreshGridView();}}
}

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 client_sideUI
{public partial class Exercise : Form{//实体类class Coure{public int Coureid { get; set; }public string CoureName { get; set; }//public String CoureHour { get; set; }}private List<Coure> ts = new List<Coure>();public Exercise(){InitializeComponent();int i = 0;foreach (Control control in this.groupBox1.Controls){//if(control is Button)//通过控件类型过滤我们不需要的控件//{//    Button button = control as Button;//    if (button.Text != "保存")//    {//        button.Tag = button.Text + $"{i}";//        button.Click += new System.EventHandler(this.btn_Click);//    }//}string originalText = control.Text;string textWithoutLastChar = originalText.Remove(originalText.Length - 1);if (control is Button && control.Text.ToString() != "保存"){// control.Tag = control.Text + $"{i}";control.Click += new System.EventHandler(this.btn_Click);string newText = textWithoutLastChar + $"{i}";control.Text = newText;}i++;}}//事件集中处理方法private void btn_Click(object sender, EventArgs e){Button btn = sender as Button;//MessageBox.Show(btn.Tag.ToString());//btn.BackColor = Color.AliceBlue;//将当前课程信息封装到课程对象,并将课程对象封装到列表中this.ts.Add(new Coure{CoureName = btn.Text,Coureid = Convert.ToInt32(btn.Text.ToString().Substring(btn.Text.Length - 1))});//改变当前按钮的背景色btn.BackColor = Color.Green;}//保存课程private void button13_Click(object sender, EventArgs e){foreach(var item in ts){//MessageBox.Show($"{item.CoureName}" +$"{item.Coureid}");Console.WriteLine($"{item.CoureName}" +"----"+$"{item.Coureid}");}}}}

http://www.mmbaike.com/news/88196.html

相关文章:

  • 南昌市做网站公司爱站seo工具包下载
  • 免费asp网站空间网站快速有排名
  • 软件定制开发公司地址郑州网站建设优化
  • 门户网站建设需要注意什么品牌推广的意义
  • 国外有个专门做麋鹿测试的网站网络销售这个工作到底怎么样
  • 给网站如何做飘窗百度标注平台怎么加入
  • 网站开发安全文档腾讯控股第三季度营收1401亿
  • 网站建设整改情况如何做一个网页
  • 网站搜索功能网络推广平台几大类
  • wordpress+景点模板黑帽seo技术培训
  • 为某网站做网站推广策划方案台州关键词优化平台
  • 大数据人工智能培训班广州seo网站开发
  • 电子商务网站建设可行性 分析搜索关键词优化排名
  • 重庆做网站找谁现在最好的免费的建站平台
  • 静态网站 动态网站seo实战培训学校
  • 成都高端网站建设网络舆情监控系统
  • 淮安集团网站建设资源搜索引擎搜索神器网
  • 网站怎么做淘宝客免费注册个人网站不花钱
  • 专门做恐怖片的网站网站搭建流程
  • 轻量应用服务器做网站长沙网站托管优化
  • 公司网站维护费怎么做分录cms快速建站
  • 贵阳网站开发方舟网络企业文化内容范本
  • 闵行做网站费用学习软件
  • 香港个人网站可以做商业的最新seo视频教程
  • 成都网站设计最加科技关键词免费
  • 建了一个网站 如何找到放图片的文件夹百度一下就知道首页
  • 浙江做网站公司排名搜索引擎优化公司
  • 戴尔网站建设规划bt樱桃 磁力岛
  • wordpress主题开发时间抖音seo排名
  • 怎么查看网站的pv uv百度指数教程