首页 > 编程语言 >依照教程实现了动态的侧边栏(C#)

依照教程实现了动态的侧边栏(C#)

时间:2023-10-17 18:55:35浏览次数:23  
标签:教程 C# System 侧边 Height Width textonecontainer using sidebar

心得说明

原来C#的动态效果是通过timer组件的运用实现的(start、stop);

真的直接发现了各个组件的属性的重要性,不然真的很难解决问题;

这里我觉得吧,先把组件的各个属性搞清楚,那么搭建系统就不会云里雾里了,首先逻辑就会很清晰了~

后端具体代码

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 testcsharp001
{
    public partial class Form1 : Form
    {
        bool sidebarExpand;
        bool oneExpand;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void sidebar_timer(object sender, EventArgs e)
        {
            if (sidebarExpand)
            {
                sidebar.Width -= 10;
                if (sidebar.Width == sidebar.MinimumSize.Width)
                {
                    sidebarExpand = false;
                    sidebarTimer.Stop();
                }
            }
            else
            {
                sidebar.Width += 10;
                if (sidebar.Width == sidebar.MaximumSize.Width)
                {
                    sidebarExpand = true;
                    sidebarTimer.Stop();
                }
            }
        }

        private void menu_Click(object sender, EventArgs e)
        {
            sidebarTimer.Start();
        }

        private void onetimer_Tick(object sender, EventArgs e)
        {
            if (oneExpand)
            {
                textonecontainer.Height += 10;
                if (textonecontainer.Height == textonecontainer.MaximumSize.Height)
                {
                    oneExpand = false;
                    onetimer.Stop();
                }
            }
            else
            {
                textonecontainer.Height -= 10;
                if (textonecontainer.Height == textonecontainer.MinimumSize.Height)
                {
                    oneExpand = true;
                    onetimer.Stop();
                }
            }
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            onetimer.Start();
        }
    }
}

标签:教程,C#,System,侧边,Height,Width,textonecontainer,using,sidebar
From: https://www.cnblogs.com/liuzijin/p/17770425.html

相关文章

  • centos安装jenkins
    使用jenkins的安装仓库sudowget-O/etc/yum.repos.d/jenkins.repohttps://pkg.jenkins.io/redhat-stable/jenkins.reposudorpm--importhttps://pkg.jenkins.io/redhat-stable/jenkins.io.keysudorpm--importhttps://pkg.jenkins.io/redhat/jenkins.io.key使用y......
  • 【发现一个问题】macos m2 下无法使用 x86_64-linux-musl-gcc 链接含有 avx512 指令
    作者:张富春(ahfuzhang),转载时请注明作者和引用链接,谢谢!cnblogs博客zhihuGithub公众号:一本正经的瞎扯一开始是使用golang中的cgo来编译:envCC=cCGO_ENABLED=1GOOS=linuxGOARCH=amd64\CGO_CFLAGS="-mavx-mavx2-mavx512f-mavx512vl-mavx512bw-O2"\gobu......
  • CSS:@keyframes和animation
    一、@keyframes定义动画通过@keyframes规则,您能够创建动画。创建动画的原理是,将一套CSS样式逐渐变化为另一套样式。在动画过程中,您能够多次改变这套CSS样式。以百分比来规定改变发生的时间,或者通过关键词"from"和"to",等价于0%和100%。0%是动画的开始时间,100%动画......
  • (一)AppScan的安装及破解
    IBMAppScan是一款目前最好用的Web应用安全测试工具,RationalAppScan可自动化Web应用的安全漏洞评估工作,能扫描和检测所有常见的Web应用安全漏洞,例如SQL注入(SQL-injection)、跨站点脚本攻击(cross-sitescripting)、缓冲区溢出(bufferoverflow)及最新的Flash/Flex应用及Web......
  • FISCO-BCOS[WeBASEUtils工具类]
    packagepriv.pront.PetStore.utils;importcn.hutool.core.lang.Dict;importcn.hutool.http.Header;importcn.hutool.http.HttpRequest;importcn.hutool.http.HttpResponse;importcn.hutool.json.JSONArray;importcn.hutool.json.JSONObject;importcn.hutool.j......
  • 无涯教程-NumPy - 左移运算符函数
    numpy.left_shift()函数将数组元素的二进制向左移动指定位置,从右边追加等号0。importnumpyasnpprint'Leftshiftof10bytwopositions:'printnp.left_shift(10,2)print'\n'print'Binaryrepresentationof10:'printnp.binary_repr(10,width=......
  • 在云主机上搭建代码svn代码服务器教程
    svn不多做介绍了。需要自己购买一台云主机,并有一个固定的外网ip。VisualSVNserver下载地址https://www.visualsvn.com/server/download/注意下载位数要和服务器一致。然后在服务器上安装这个svnserver,一直默认下一步只到安装完成。启动svnserver,设置ip端口和https等信息。......
  • VSCode 设置文件显示和搜索过滤
    打开setting.json {"search.exclude":{"**/node_modules":true,"**/bower_components":true,"dist/":true,"build/":true,"temp/":true,......
  • 使用C#中的Panel组件时,它一直按照左上角为基准对齐
    是这里出了问题点击Panel之后,在右边属性列表中就能看见有一个名Anchor为的属性,它默认是Top,Left的定义值;所以Panel才是一直以左上角为基准变化;现在将其改为Bottom属性:然后Panel的排列布局就会下一个挨着上一个的底部啦~如图所示:......
  • What is click event?
    先不去讨论它语法、原理,先描述一下它的功能性,Clickevent想要实现的效果是?开发者在UI界面上放置一个按钮,并且开发者写了一段功能函数,当有人点击了这个UI按钮,就会自动去执行这段功能函数。这就是点击按钮想要的效果。点击事件的实现原理思考常见的按钮点击事件的简要实现......