An autoscrollable panel used by ControlList to host the TableLayoutPanel. Essentially adds a scrollbar to TableLayout
Inheritance: System.Windows.Forms.ScrollableControl
Exemple #1
0
        private void ControlList_Load(object sender, EventArgs e)
        {
            // Build a scrollable control and add a table layout to it.
            this.tableLayout = new TableLayoutPanel();

            this.scrollPanel = new ScrollPanel();
            scrollPanel.Size = this.Size;

            scrollPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                        | System.Windows.Forms.AnchorStyles.Left)
                                                                       | System.Windows.Forms.AnchorStyles.Right)));

            this.Controls.Add(scrollPanel);
            this.scrollPanel.Controls.Add(this.tableLayout);

            this.tableLayout.ColumnCount = 1;
            this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
            this.tableLayout.Location = new System.Drawing.Point(0, 0);
            this.tableLayout.Margin   = new System.Windows.Forms.Padding(0);
            this.tableLayout.Name     = "tableLayout";
            this.tableLayout.RowCount = 1;
            this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 149F));
            this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 149F));

            this.tableLayout.Size = scrollPanel.Size;

            this.tableLayout.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top)
                                                                             | System.Windows.Forms.AnchorStyles.Left)
                                                                            | System.Windows.Forms.AnchorStyles.Right)));
            // Don't anchor to the bottom; if you do, the table control will be too big and won't scroll right.
            //| System.Windows.Forms.AnchorStyles.Bottom));

            this.tableLayout.TabIndex = 2;

            Console.WriteLine(this.Width);
            Console.WriteLine(this.scrollPanel.Width);
            Console.WriteLine(this.tableLayout.Width);

            foreach (RowStyle style in this.tableLayout.RowStyles)
            {
                style.SizeType = SizeType.Absolute;
            }

            this.ContextMenu = new ContextMenu();

            UpdateTableHeight();
        }
Exemple #2
0
        private void ControlList_Load(object sender, EventArgs e)
        {
            
            // Build a scrollable control and add a table layout to it.
            this.tableLayout = new TableLayoutPanel();

            this.scrollPanel=new ScrollPanel();
            scrollPanel.Size = this.Size;

            scrollPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
            | System.Windows.Forms.AnchorStyles.Left)
            | System.Windows.Forms.AnchorStyles.Right)));

            this.Controls.Add(scrollPanel);
            this.scrollPanel.Controls.Add(this.tableLayout);

            this.tableLayout.ColumnCount = 1;
            this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
            this.tableLayout.Location = new System.Drawing.Point(0, 0);
            this.tableLayout.Margin = new System.Windows.Forms.Padding(0);
            this.tableLayout.Name = "tableLayout";
            this.tableLayout.RowCount = 1;
            this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 149F));
            this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 149F));

            this.tableLayout.Size = scrollPanel.Size;

            this.tableLayout.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top)
                | System.Windows.Forms.AnchorStyles.Left)
                | System.Windows.Forms.AnchorStyles.Right)));
            // Don't anchor to the bottom; if you do, the table control will be too big and won't scroll right.
            //| System.Windows.Forms.AnchorStyles.Bottom));

            this.tableLayout.TabIndex = 2;

            Console.WriteLine(this.Width);
            Console.WriteLine(this.scrollPanel.Width);
            Console.WriteLine(this.tableLayout.Width);

            foreach (RowStyle style in this.tableLayout.RowStyles)
                style.SizeType = SizeType.Absolute;

            this.ContextMenu = new ContextMenu();

            UpdateTableHeight();
        }