Detecting presence of scrollbars in a ListView

  • Thread starter Thread starter Dilip
  • Start date Start date
D

Dilip

I inherited an owner drawn control that subclasses the Windows Forms
ListView control to provide additional functionalities. I wanted to
detect the presence of the Vertical scrollbar so that I can disable a
few buttons. This code didn't work:

foreach (Control c in ownerDrawnListViewObject.Controls)
{
if (c is VScrollBar)
{
return c.Visible;
}
}

This didn't work because, to my surprise,
ownerDrawnListViewObject.Controls.Count returned 0!

Am I going about this the wrong way?
 
I inherited an owner drawn control that subclasses the Windows Forms
ListView control to provide additional functionalities.  I wanted to
detect the presence of the Vertical scrollbar so that I can disable a
few buttons.  This code didn't work:

foreach (Control c in ownerDrawnListViewObject.Controls)
{
    if (c is VScrollBar)
    {
        return c.Visible;
    }

}

This didn't work because, to my surprise,
ownerDrawnListViewObject.Controls.Count returned 0!

Am I going about this the wrong way?

I think you should check for "listView.Scrollable" and work around it
to detect horizontal and veritical

-Cnu
 
I think you should check for "listView.Scrollable" and work around it
to detect horizontal and veritical

-Cnu

I believe ListView.Scrollable only ensures that the scrollbars will
show up if the entries in the ListView cannot be exceed the
displayable area. If you have only one or 2 entries for which no
scrollbar would show up, ListView.Scrollable would still return true.
That is now what I am after.
 
Sorry.. I have a bad case of butter fingers. Let me try again:

I believe ListView.Scrollable only ensures that the scrollbars will
show up if the entries in the ListView exceed the displayable area.
If you have only one or 2 entries for which no
scrollbar would show up, ListView.Scrollable would still return true.
That is not what I am after.
 
Back
Top