欢迎莅临 SUN WU GANG 的园子!!!

世上无难事,只畏有心人。有心之人,即立志之坚午也,志坚则不畏事之不成。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  470 随笔 :: 0 文章 :: 22 评论 :: 30万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
复制代码
   /// <summary>
        /// 获取TableLayoutPanel指定行的高度
        /// </summary>
        /// <param name="layout">TableLayoutPanel</param>
        /// <param name="row">行号</param>
        /// <returns>行高</returns>
        public float GetTlpRowHeight(TableLayoutPanel layout, int row)
        {
            float height = 0;
            int count = layout.RowCount;
            if (row > count) return 0;

            for (int i = 1; i <= count; i++)
            {
                if (!i.Equals(row)) continue;
                height = layout.RowStyles[i].Height;
                break;
            }
            return height;
        }

        /// <summary>
        /// 设置TableLayoutPanel指定行的高度
        /// </summary>
        /// <param name="layout">TableLayoutPanel</param>
        /// <param name="row">行号</param>
        /// <returns>行高</returns>
        public void SetTlpRowHeight(TableLayoutPanel layout, int row, float height)
        {
            int count = layout.RowCount;
            if (row > count) return;

            for (int i = 0; i <= count; i++)
            {
                if (i == row)
                {
                    layout.RowStyles[i].Height = height;
                    return;
                }
            }
        }

        /// <summary>
        /// 获取TableLayoutPanel指定行的宽度
        /// </summary>
        /// <param name="layout">TableLayoutPanel</param>
        /// <param name="row">行号</param>
        /// <returns>行宽</returns>
        public float GetTlpColWidth(TableLayoutPanel layout, int col)
        {
            float width = 0;
            try
            {
                int count = layout.ColumnCount;
                if (col > count) return 0;

                for (int i = 0; i <= count; i++)
                {
                    if (!i.Equals(col)) continue;
                    width = layout.ColumnStyles[i].Width;
                    break;
                }
            }
            catch
            {
                return width;
            }
            return width;
        }

        /// <summary>
        /// 设置TableLayoutPanel指定行的宽度
        /// </summary>
        /// <param name="layout">TableLayoutPanel</param>
        /// <param name="row">行号</param>
        /// <returns>行宽</returns>
        public void SetTlpColWidth(TableLayoutPanel layout, int col, float width)
        {
            try
            {
                int count = layout.ColumnCount;
                if (col > count) return;

                for (int i = 0; i <= count; i++)
                {
                    if (i == col)
                    {
                        layout.ColumnStyles[i].Width = width;
                        return;
                    }
                }
            }
            catch { return; }
        }
复制代码

TableLayoutPanel1.ColumnStyles[列序号].Width = 0; 
TableLayoutPanel1.RowStyles[行序号].WidthHeight = 0;

posted on   sunwugang  阅读(9004)  评论(2编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示