当前位置:网站首页>C#应用程序界面开发基础——窗体控制(5)——分组类控件
C#应用程序界面开发基础——窗体控制(5)——分组类控件
2022-07-05 19:19:00 【DXB2021】
分组类控件
分组类控件有容器(Panel)控件、分组框(GroupBox)控件、选项卡(TabControl)控件等。
容器控件
容器控件是由System.Windows.Forms.Panel类提供的。该控件相当于一个容器,主要作用就是将其它控件组合在一起放在一个面板上,使这些控件更容易管理。
编写程序,制作一个“下载资源管理器”。
开发步骤如下:
1、首先在Form1窗体中添加三个Button控件,并修改这些控件的Text属性;然后再添加一个Panel控件,并将该控件的Size属性设置为“307,181”。
2、接着再新建三个窗体,分别 为Regular.cs常规窗体、Download.cs下载窗体和Appearance.cs外观窗体,并且为三个窗体添加相应的控件。这里还需要注意,窗体新建完成之后 ,也需要将它们的Size属性设置为“307,181”。
右键,选择重命名。
3、最后在Form1.cs文件中,添加三个Button控件的Click事件。
代码之前
代码之后:
代码如下:
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 WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Regular myRegular=new Regular();
myRegular.TopLevel = false;
this.panel1.Controls.Add(myRegular);
myRegular.FormBorderStyle= FormBorderStyle.None;
myRegular.BringToFront();
myRegular.Show();
}
private void button2_Click(object sender, EventArgs e)
{
Download myDownload = new Download();
myDownload.TopLevel = false;
this.panel1.Controls.Add(myDownload);
myDownload.FormBorderStyle = FormBorderStyle.None;
myDownload.BringToFront();
myDownload.Show();
}
private void button3_Click(object sender, EventArgs e)
{
Appearance myAppearance = new Appearance();
myAppearance.TopLevel = false;
this.panel1.Controls.Add(myAppearance);
myAppearance.FormBorderStyle = FormBorderStyle.None;
myAppearance.BringToFront();
myAppearance.Show();
}
}
}
运行结果如下:
点击,无反应, 运行失败。
三个窗口重新设计:
再次运行:
分组框控件
分组框控件是由System.Windows.Forms.GroupBox类提供的,作用是为其他控件提供可识别的分组,可在同一页面实现多个单选RadioButton控件。通常,使用分组框来按功能细分窗体。
选项卡控件
选项卡控件是一个选项卡控件,在实际 编程中经常用到,该控件的作用是将相关的组件组合到一系列选项卡页面上。
1、添加和删除TabControl控件中的选项卡
2、以编程方式添加和删除选项卡。
边栏推荐
- JAD installation, configuration and integration idea
- Hiengine: comparable to the local cloud native memory database engine
- Debezium系列之:postgresql从偏移量加载正确的最后一次提交 LSN
- Technology sharing | interface testing value and system
- Bitcoinwin (BCW)受邀参加Hanoi Traders Fair 2022
- 软件测试工程师是做什么的?待遇前景怎么样?
- HAC集群修改管理员用户密码
- CF: B. almost Ternary Matrix [symétrie + règles de recherche + Construction + I am Construction Waste]
- android中常见的面试题,2022金九银十Android大厂面试题来袭
- Ten years at sea: old and new relay, dark horse rising
猜你喜欢
Fuzor 2020软件安装包下载及安装教程
【硬核干货】数据分析哪家强?选Pandas还是选SQL
如何实现游戏中的在线计时器和离线计时器
【C语言】字符串函数及模拟实现strlen&&strcpy&&strcat&&strcmp
如何在2022年更明智地应用智能合约?
What are the reliable domestic low code development platforms?
【FAQ】华为帐号服务报错 907135701的常见原因总结和解决方法
Common interview questions in Android, 2022 golden nine silver ten Android factory interview questions hit
Debezium系列之:记录mariadb数据库删除多张临时表debezium解析到的消息以及解决方法
Django uses mysqlclient service to connect and write to the database
随机推荐
5年经验Android程序员面试27天,2022程序员进阶宝典
【硬核干货】数据分析哪家强?选Pandas还是选SQL
Ten years at sea: old and new relay, dark horse rising
Reptile exercises (II)
Shell编程基础(第8篇:分支语句-case in)
HAC cluster modifying administrator user password
Postman核心功能解析-参数化和测试报告
PHP uses ueditor to upload pictures and add watermarks
100million single men and women supported an IPO with a valuation of 13billion
Fundamentals of shell programming (Chapter 9: loop)
软件测试工程师是做什么的?待遇前景怎么样?
ELK分布式日志分析系统部署(华为云)
UWB ultra wideband positioning technology, real-time centimeter level high-precision positioning application, ultra wideband transmission technology
How to choose the notion productivity tools? Comparison and evaluation of notion, flowus and WOLAI
HAC集群修改管理员用户密码
JAD的安装、配置及集成IDEA
618“低调”谢幕,百秋尚美如何携手品牌跨越“不确定时代”?
Bitcoinwin (BCW)受邀参加Hanoi Traders Fair 2022
什么是面上项目
What do software test engineers do? How about the prospect of treatment?