zoukankan      html  css  js  c++  java
  • TableLayoutPanel 行高列宽设置

       /// <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 = 1; 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; }
            }
  • 相关阅读:
    mysql索引及优化
    mysql5.5 uuid做主键与int做主键的性能实测
    php生成UUID
    Android 图片的裁剪与相机调用
    Android GPS 临近触发
    Android中GPS类及方法简介
    永久删除 tadb.exe
    linux服务器调整参数支持高并发
    隐藏nginx 版本号信息
    nginx 重写 rewrite 基础及实例
  • 原文地址:https://www.cnblogs.com/YYkun/p/8037405.html
Copyright © 2011-2022 走看看