autoscroll panel to bottom

后端 未结 3 1943
灰色年华
灰色年华 2020-12-20 14:22

i have a panel in my winforms and in it i load some usercontrols .

i would like to autoscroll to the bottom of the panel( as my panel fills ) everytime a new userco

3条回答
  •  天命终不由人
    2020-12-20 15:00

    I found that continuously adding controls to the panel at vertical increments would be affected negatively whenever a user had scrolled the panel up or down. I used the tip from Homam above, and found the following to work well:

    panel1.VerticalScroll.Value = 0;
    
    // Creating and adding a TextBox, tb, to the panel
    
    panel1.ScrollControlIntoView(tb);
    

    So first, I scroll to the top in order to use absolute vertical positions for my text boxes, then I place the Text Box, and finally, I make sure that the newly created text box comes into view.

提交回复
热议问题