Winform控件之TableLayoutPanel

TableLayoutPanel在动态加载control时使用SuspendLayout()  和  ResumeLayout()有时会导致控件不显示。

 

使用示例:

filePanel.RowCount = rowIndex + tempDic.Sum(n => n.Value.Count) + 1;
            this.filePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));

            foreach (string folderName in tempDic.Keys)
            {
                LabelX folderControl = RegularLabel(folderName);
                //Label folderControl = RegularLabel1(folderName);
                filePanel.Controls.Add(folderControl, 0, rowIndex);
                filePanel.SetRowSpan(folderControl, tempDic[folderName].Count);

                foreach (RegularFileInfo fileInfo in tempDic[folderName])
                {
                    this.filePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));
                    LabelX extensionControl = RegularLabel(fileInfo.FileExtension);
                    filePanel.Controls.Add(extensionControl, 2, rowIndex);

                    LabelX fileControl = FileLabel(fileInfo);
                    filePanel.Controls.Add(fileControl, 1, rowIndex);
                    rowIndex++;
                }
            }

 

posted @ 2022-06-29 13:18  白草红叶黄花  阅读(1046)  评论(0编辑  收藏  举报