Detecting presence of scrollbars in a ListView

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?
 
D

Duggi

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
 
D

Dilip

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.
 
D

Dilip

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top