我注意到System.Windows.Forms.Panel
上的滚动条似乎在垂直滚动条的左侧有一条白线。
当我将DevExpress.XtraEditors.XtraScrollableControl
设置为true时,我也注意到UseWindowsXPTheme
,所以我猜测它可能是一个系统事物(因为这是举个例子,我没有用DevExpress标签标记这个问题。)
我注意到在Visual Studio 2015选项屏幕中,它有一个带有此白线的滚动条示例(左侧的那个),没有它(右侧的那个):
我的问题是:有没有办法从滚动条中删除此白线?如果是这样,怎么样?我知道它可能看起来很小,但它很明显很烦人。
我已将此问题标记为VB.NET和C#,因为我很乐意接受任何一种语言的答案。
答案 0 :(得分:0)
除非您使用自己的自定义控件进行滚动,否则无法执行此操作。这只是滚动条上的3D高亮效果,滚动条没有覆盖属性可将其样式更改为平面。
但是这里有一些你可以使用的花哨的自定义滚动条。
CodeProject: Cool Scrollbar - Scrollbar like Windows Media Player's
CodeProject: How to skin scrollbars for Panels, in C#
CodeProject: Replace a Window's Internal Scrollbar with a customdraw scrollbar Control
答案 1 :(得分:0)
好吧,在研究了诸如handling the Paint event for a Scrollbar control之类的内容之后,我最终想出了一个更容易,更简单(但最终不舒服)的解决方案:用Label
控件覆盖它!
这将为Panel
:
Dim key As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion")
Dim operatingSystem As String = ""
If key IsNot Nothing
operatingSystem = key.GetValue("ProductName")
End If
If operatingSystem.Contains("Windows 10")
Dim verticalHiderLabel As New Label With { .Location = New Point(Panel1.Right - SystemInformation.VerticalScrollBarWidth-1, Panel1.Top+1),
.Size = New Size(1, Panel1.Height - SystemInformation.HorizontalScrollBarHeight-1)}
Dim horizontalHiderLabel As New Label With {.Location = New Point(Panel1.Left+1, Panel1.Bottom - SystemInformation.HorizontalScrollBarHeight-1),
.Size = New Size(Panel1.Width - SystemInformation.VerticalScrollBarWidth-1, 1)}
Me.Controls.Add(verticalHiderLabel)
Me.Controls.Add(horizontalHiderLabel)
verticalHiderLabel.BringToFront()
horizontalHiderLabel.BringToFront()
End If
由于我在任何其他操作系统上都没有看到此问题,因此我添加了一项检查,以确保它仅在Windows 10上启用,不幸的是,它使用了注册表,我不确定是否有可靠的方法在Windows 10上进行检查。
显然,如果有人使用带有滚动条的可调整大小的Control
,他们会相应地更新Label
尺寸。