0
public partial class Form1 : Form
    {
        public System.Windows.Forms.ScrollBars ScrollBars { get; set; }

        private int startingY = 0;
        private GroupBox lastGB = null;
        private int timerCounter = 0;

        public Form1()
        {
            InitializeComponent();

            textBox1.SizeChanged += (s, e) => { UpdateLabelPositions(); };
            textBox1.LocationChanged += (s, e) => { UpdateLabelPositions(); };
            this.Shown += (s, e) => { UpdateLabelPositions(); };

            textBox1.Multiline = true;
            textBox1.ScrollBars = ScrollBars.Vertical;
        }

but the textBox scroll bar is grayed out disabled even if I'm adding to it many items.

I'm adding to the textBox many groupboxes but like in the screenshot they are added down inside the textbox and the textbox don't have enabled scrollbars. I tried also in the designer to set the scroll bars to BOTH but it didn't change anything.

  • 3
    Wait.. you're adding Controls inside TextBox? Why not a proper container like Panel? – Martheen Nov 20 '20 at 02:09
  • @Martheen I changed it to panel and still it's not scrolling. and I can't find in the designer of the panel where and how to set and enable the scrollbars. but as before with the textbox also with the panel no scrollbars. – Daniel Lipman Nov 20 '20 at 03:32
  • See https://stackoverflow.com/questions/6090558/add-vertical-scroll-bar-to-panel and https://stackoverflow.com/questions/5489273/how-do-i-disable-the-horizontal-scrollbar-in-a-panel – Martheen Nov 20 '20 at 03:36

1 Answers1

2

I recreated a basic Panel with 4 GroupBoxes inside and set AutoScroll to true and the vertical scroll bar displayed as expected:

Panel with scroll bar

Obviously, AutoSize must be set to false, so is it possible that you have some conflicting properties set?

SteveCinq
  • 1,920
  • 1
  • 17
  • 22