Hide vertical scroll bar in ListBox control
The problem was solved. I've simply created a new project of template a class library with the following code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ClassLibrary1
{
public class MyListBox : System.Windows.Forms.ListBox
{
private bool mShowScroll;
protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
if (!mShowScroll)
cp.Style = cp.Style & ~0x200000;
return cp;
}
}
public bool ShowScrollbar
{
get { return mShowScroll; }
set
{
if (value != mShowScroll)
{
mShowScroll = value;
if (IsHandleCreated)
RecreateHandle();
}
}
}
}
}
Then, I've built the project outputting a new class library ClassLibrary1.dll
On my main project, I've right-clicked the ToolBox
and selected Choose Items...
. Clicked on Browse... and selected the class library that I've recently created (ClassLibrary1.dll) and clicked on Open then on OK. Thus, I was able to have my custom ListBox
which has no vertical scroll bars anymore.
Picrofo Software
Trying to help people all over the world to overcome their problems with Windows machines by faster, flexible and comfortable ways. Social Media Picrofo Software on Facebook Picrofo Software on Twitter Picrofo Software on Pinterst Picrofo Software on Microsoft Community Picrofo Software on LinkedIn Try something new, an online Linux shell without restrictions: https://picrofo.com/clinux/
Updated on June 15, 2022Comments
-
Picrofo Software almost 2 years
I'm developing an application that requires a
ListBox
control. Unfortunately, when I add too many items in theListBox
, a vertical scroll bar is shown. Is there something I can do to hide the vertical scroll bar shown by theListBox
? I can see that there's a property to hide the horizontal scroll bar but there's no property for the vertical scroll bar.