Unable to enable scroll in tablelayoutpanel in C#

北城以北 提交于 2019-12-13 04:53:54

问题


I am using a tablelayout panel in my project and displaying items in it . but it is not scrollable , i have tried with autoscroll, maximum size and everything else that seems related to scrolling .

Any kind of help will be appreciated , many thanks , plz help


回答1:


In order to auto scroll show any kind of scroll bar its parent control must be smaller than the TableLayoutPanel itself. Check you parent size and other properties, such as autosize, dock and autosizemode




回答2:


I'm not sure what you're designing for that control, but it really implemente the interface IScrollable (just like this name, you could view it in object browser).

Here is mine.

// 
        // tableLayoutPanel1
        // 
        this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
        | System.Windows.Forms.AnchorStyles.Left)));
        this.tableLayoutPanel1.AutoScroll = true;
        this.tableLayoutPanel1.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
        this.tableLayoutPanel1.ColumnCount = 2;
        this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
        this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
        this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 12);
        this.tableLayoutPanel1.Name = "tableLayoutPanel1";
        this.tableLayoutPanel1.RowCount = 1;
        this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
        this.tableLayoutPanel1.Size = new System.Drawing.Size(686, 515);
        this.tableLayoutPanel1.TabIndex = 0;
        // 

Hope this could help you, I use it just now.



来源:https://stackoverflow.com/questions/11839846/unable-to-enable-scroll-in-tablelayoutpanel-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!