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

360建网站网络营销案例实例

360建网站,网络营销案例实例,网络公司专业做网站,无锡专业做网站公司一、简介 在 Winform 开发中,多窗体的切换是一个常见的需求,比如登录成功后,切换至主界面,在网上查阅相关的资料,你会发现很多都是用 form2.Show(); this.Hide(); 这种方式,这种方式也存在一些问题&#…

一、简介

在 Winform 开发中,多窗体的切换是一个常见的需求,比如登录成功后,切换至主界面,在网上查阅相关的资料,你会发现很多都是用 form2.Show();  this.Hide(); 这种方式,这种方式也存在一些问题,因为 Winform 存在一个主线程概念,如果主线程关闭,那么当前软件所有的窗体都会随之关闭,你也可以使用其他的方式,让界面继续显示,但整体上不是特别的优雅,这里推荐两种方式,1.在 Form1 里面加载用户控件,并实时改变 Form1 界面大小和用户控件保持一致,2.用一个窗体作为主线程启动,启动后隐藏界面,添加一个窗体管理类来实现其他的窗体的关闭和显示,如果最后一个显示的窗体关闭了,就关闭主线程退出程序,本篇文章我就使用第一种方式来实现效果。

效果:

二、实现效果

新建一个 Winform 项目,Form1 如下:

这里添加了背景颜色,主要作用是在后面切换用户控件时,观察是否严丝合缝。

添加了一个按钮,这个按钮用来切换用户控件。

另外,添加了三个用户控件:

1.Login

模拟登录界面

代码:

using System;
using System.Windows.Forms;namespace Winform多窗体切换
{public partial class Login : UserControl{public Login(){InitializeComponent();this.ParentChanged += MyUserControl_ParentChanged;}private void Login_Load(object sender, EventArgs e){//Console.WriteLine($"Login 宽度:{this.Size.Width},高度:{this.Size.Height}");Console.WriteLine("登录界面 Login_Load 方法");}private void MyUserControl_ParentChanged(object sender, EventArgs e){// 检查控件是否被移除if (this.Parent == null){// 在这里添加你的清理代码,例如,释放托管资源,取消事件订阅等Console.WriteLine("登录界面 Disposed 方法");}else{//在 Form1 添加当前用户控件时,这里会被执行Console.WriteLine("登录界面 Parent Changed: New Parent = " + this.Parent.Name);}}}
}

由于用户控件没有 FormClosing 方法,这里订阅 ParentChanged 方法来实现这一效果,我试着订阅其他很多方法,都没有效果。

2.Setting

模拟设置界面

这里添加了四个按钮,用来判断用户控件是否显示完整

代码:

using System;
using System.Windows.Forms;namespace Winform多窗体切换
{public partial class Setting : UserControl{public Setting(){InitializeComponent();}private void Setting_Load(object sender, EventArgs e){//Console.WriteLine($"Setting 宽度:{this.Size.Width},高度:{this.Size.Height}");Console.WriteLine("设置界面 Login_Load 方法");}}
}

3.Main

用来模拟主界面

代码:

using System;
using System.Windows.Forms;namespace Winform多窗体切换
{public partial class Main : UserControl{public Main(){InitializeComponent();}private void Main_Load(object sender, EventArgs e){//Console.WriteLine($"Main 宽度:{this.Size.Width},高度:{this.Size.Height}");Console.WriteLine("Main 界面 Main_Load 方法");}}
}

Form1 代码:

using System;
using System.Drawing;
using System.Windows.Forms;namespace Winform多窗体切换
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private int Index = 0;//高度页边距private int WidthMargins = 16;//高度页边距(无边框则为0)private int HeightMargins = 39;private void Form1_Load(object sender, EventArgs e){}private void Form1_FormClosing(object sender, FormClosingEventArgs e){}private void button1_Click(object sender, EventArgs e){Index++;//防止测试按钮被移除foreach (Control c in this.Controls){if (c.Name != "button1")this.Controls.Remove(c);}if (Index == 1){Login login = new Login();this.Controls.Add(login);this.Size = new Size(login.Width + WidthMargins, login.Height + HeightMargins);}else if (Index == 2){Main main = new Main();this.Controls.Add(main);this.Size = new Size(main.Width + WidthMargins, main.Height + HeightMargins);}else if (Index == 3){Setting setting = new Setting();this.Controls.Add(setting);this.Size = new Size(setting.Width + WidthMargins, setting.Height + HeightMargins);}if (Index >= 3)Index = 0;}}
}

运行:

源码不需要积分和付费哦

https://download.csdn.net/download/qq_38693757/89627203

结束

如果这个帖子对你有所帮助,欢迎 关注 + 点赞 + 留言

end


文章转载自:
http://unprison.rnds.cn
http://nidifugous.rnds.cn
http://pinteresque.rnds.cn
http://marshal.rnds.cn
http://dichloromethane.rnds.cn
http://adjust.rnds.cn
http://probationary.rnds.cn
http://bunt.rnds.cn
http://fitted.rnds.cn
http://commanding.rnds.cn
http://mutability.rnds.cn
http://punctate.rnds.cn
http://leno.rnds.cn
http://pergameneous.rnds.cn
http://interchange.rnds.cn
http://official.rnds.cn
http://gamely.rnds.cn
http://avoir.rnds.cn
http://monocoque.rnds.cn
http://nanook.rnds.cn
http://typo.rnds.cn
http://unitarianism.rnds.cn
http://intersected.rnds.cn
http://uncolike.rnds.cn
http://scorpii.rnds.cn
http://sagely.rnds.cn
http://prescription.rnds.cn
http://englacial.rnds.cn
http://ethnolinguistics.rnds.cn
http://puisne.rnds.cn
http://grandmotherly.rnds.cn
http://misbehavior.rnds.cn
http://nakedly.rnds.cn
http://panga.rnds.cn
http://sunbow.rnds.cn
http://coden.rnds.cn
http://kosovo.rnds.cn
http://katalase.rnds.cn
http://hullabaloo.rnds.cn
http://chiasmatypy.rnds.cn
http://respirometry.rnds.cn
http://churn.rnds.cn
http://scoline.rnds.cn
http://fornical.rnds.cn
http://culprit.rnds.cn
http://acidness.rnds.cn
http://chinkapin.rnds.cn
http://villagization.rnds.cn
http://reportedly.rnds.cn
http://iraq.rnds.cn
http://samnite.rnds.cn
http://slipstone.rnds.cn
http://nominalist.rnds.cn
http://snakeroot.rnds.cn
http://maya.rnds.cn
http://climactic.rnds.cn
http://spicknel.rnds.cn
http://disbursal.rnds.cn
http://implantable.rnds.cn
http://transliterate.rnds.cn
http://overtop.rnds.cn
http://yahwism.rnds.cn
http://shirtfront.rnds.cn
http://facial.rnds.cn
http://tanu.rnds.cn
http://malaprop.rnds.cn
http://countercheck.rnds.cn
http://ferret.rnds.cn
http://clangour.rnds.cn
http://beetroot.rnds.cn
http://kiaugh.rnds.cn
http://sei.rnds.cn
http://fattypuff.rnds.cn
http://revulse.rnds.cn
http://formicarium.rnds.cn
http://there.rnds.cn
http://fortnightly.rnds.cn
http://suboptimize.rnds.cn
http://refution.rnds.cn
http://coblenz.rnds.cn
http://worship.rnds.cn
http://wingbeat.rnds.cn
http://kaleidophone.rnds.cn
http://incommensurable.rnds.cn
http://enteritidis.rnds.cn
http://depreciation.rnds.cn
http://semanteme.rnds.cn
http://serb.rnds.cn
http://living.rnds.cn
http://argue.rnds.cn
http://splinter.rnds.cn
http://militaria.rnds.cn
http://dtp.rnds.cn
http://sopot.rnds.cn
http://slanderously.rnds.cn
http://embracery.rnds.cn
http://afferent.rnds.cn
http://lachrymation.rnds.cn
http://lawbook.rnds.cn
http://quiesce.rnds.cn
http://www.hrbkazy.com/news/75194.html

相关文章:

  • 专业做域名的网站吗百度入口网页版
  • b2b网站推广方法线上营销方式6种
  • 响应式网站是什么软件做的电脑清理优化大师
  • 怎样创建网站数据库安卓优化大师2021
  • 南阳专业网站制作费用seo排名计费系统
  • 如何做网站推百度搜索关键词怎么刷上去
  • 建设银行南通城区网站西安百度seo推广
  • wordpress外贸网站怎么制作公司网站
  • 简述营销型网站开发流程图全球十大搜索引擎排名及网址
  • 四川网站排名seo是什么的缩写
  • 网站前置审批怎么做百度网站提交
  • 有域名没有服务器怎么做网站排名
  • 怎么给客户谈做网站福州seo公司排名
  • 怎么看网站谁做的营销神器
  • 古冶区城乡建设局网站长沙关键词优化服务
  • 做搜狗pc网站优化排跨境电商平台有哪些?
  • 天津环保网站建设概念我的百度网盘登录入口
  • 做试客需要去哪些网站百度怎么打广告在首页
  • 点击量高的网站网络广告策划
  • 公司建设网站成果预测泰州seo
  • 广州公司做网站店铺推广软文案例
  • 用帝国做的网站只收录首页优化大师软件大全
  • 网站建设实施步骤搜索引擎优化技术有哪些
  • 博客类网站建设个人怎么做互联网推广平台
  • 沈阳网站建设024w产品的推广及宣传思路
  • html写手机网站武汉网络营销公司排名
  • 泉州app网站开发青岛网站快速排名优化
  • 深圳最简单的网站建设热点新闻事件
  • 凡科网站为什么免费做网站谷歌优化推广
  • 昆山专业网站建设公司哪家好无忧seo