zoukankan      html  css  js  c++  java
  • C#中,重新排列panel中的按钮

    重新排列panel中的按钮,如图
    排列前:


    排列后:

    代码:
            void ArrangeButtons(Panel pn)
             {
                int x = 0, y = 0;
                 System.Windows.Forms.Control.ControlCollection ct = pn.Controls;

                //for (int i = 0; i < ct.Count; i++)
                for (int i = ct.Count - 1; i >= 0; i--)
                 {
                     ct[i].Location = new System.Drawing.Point(x, y);
                     x = x + ct[i].Width + 5;
                    if (x + ct[i].Width > pn.Width)
                     {
                         x = 0;
                         y = y + ct[i].Height + 5;
                     }
                 }
             }

            private void buttonArrangeButtons_Click(object sender, EventArgs e)
             {
                 ArrangeButtons(panel1);
             }

  • 相关阅读:
    Spring-IOC容器
    VUE 过滤器
    axios.post参数问题
    Stylus| vue项目中stylus和stylus-loader版本兼容问题
    SPA
    Options API 和 Composition API 的对比
    【ES6学习笔记之】Object.assign()
    vue element-ui 常用组件
    Vue调试工具
    组件
  • 原文地址:https://www.cnblogs.com/hfzsjz/p/1799068.html
Copyright © 2011-2022 走看看