如何使面板的标准滚动条消失? [英] How do I make the standard scrollbar of a panel disappear?

查看:112
本文介绍了如何使面板的标准滚动条消失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





在我的表格上,我有一个面板,里面有不同数量的按钮。它们都排成一排,都设置为停靠顶部。由于我不喜欢包含滚动条的设计以及缺乏改变颜色的可能性,我创建了自己的滚动条,效果很好。问题是,为了使其工作,必须将AutoScroll设置为true。现在,当内容的总高度超过面板的高度时,标准滚动条会自动出现,我无法摆脱它。



所以这是我的题。如何让滚动条消失?



我尝试过:



我试过每个组合,例如



Hey

On my form, I have a panel with a varying number of buttons. They are all placed in a row and are all set to dock top. Since I dislike the design of the included scrollbars and the lack of possibility to change the color, I created my own scrollbar, which works great. The problem is that in order for it to work, AutoScroll must be set to true. Now, when the summed height of the content exceeds the height of the panel, the standard scrollbar automatically appears and I can not get rid of it.

So here is my question. How can I make the scrollbar disappear?

What I have tried:

I tried every combination like for example

panel_Playlists.AutoScroll = false;
panel_Playlists.VerticalScroll.Enabled = false;
panel_Playlists.VerticalScroll.Visible = false;
panel_Playlists.AutoScroll = true;

推荐答案

一种方法是调用 ShowScrollBar 直接来自 user32.dll



看看在面板控件中隐藏垂直滚动条的问题。 [ ^ ]
One way is to call ShowScrollBar directly from user32.dll.

Have a look at Problem to hide vertical scrollbar in panel control.[^]


此问题的一般解决方案需要嵌套面板。允许内部面板调整大小以适合其内容,并且不显示滚动条。外部面板的AutoSize为false,AutoScroll为false。通过改变内面板的位置,它可以在外面板内移动(滚动)。



这个想法

The general solution to this problem requires nested panels. The inner panel is allowed to resize to fit it's contents and does not show scrollbars. The outer panel has AutoSize false and AutoScroll false. By changing the location of the inner panel it may be moved (scrolled) within the outer panel.

This is the idea
Panel outerPanel = new Panel();
outerPanel.AutoSize = false;
outerPanel.AutoScroll = false;
// For testing make the bounds very obvious
outerPanel.BackColor = Color.Red;
outerPanel.BorderStyle = BorderStyle.FixedSingle;

Panel innerPanel = new Panel();
innerPanel.Parent = outerPanel;
innerPanel.AutoSize = true;
innerPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
innerPanel.AutoScroll = false;
innerPanel.BorderStyle = BorderStyle.FixedSingle;
innerPanel.BackColor = Color.Blue;

// Scroll down a bit, right a bit
innerPanel.Location = new Point(-50, -30);



Alan。


Alan.


这篇关于如何使面板的标准滚动条消失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆