471,338 Members | 1,019 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

Detecting presence of scrollbars in a ListView


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?

Aug 26 '08 #1
3 4459
On Aug 27, 1:39*am, Dilip <rdil...@lycos.comwrote:
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
Aug 27 '08 #2
On Aug 27, 2:24*am, Duggi <DuggiSrinivasa...@gmail.comwrote:
On Aug 27, 1:39*am, Dilip <rdil...@lycos.comwrote:
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 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.
Aug 27 '08 #3
On Aug 27, 9:49*am, Dilip <rdil...@lycos.comwrote:
On Aug 27, 2:24*am, Duggi <DuggiSrinivasa...@gmail.comwrote:
On Aug 27, 1:39*am, Dilip <rdil...@lycos.comwrote:
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
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.

Aug 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by MrNobody | last post: by
1 post views Thread by TomasFloyd | last post: by
2 posts views Thread by ohadasor | last post: by
3 posts views Thread by John Kraft | last post: by
1 post views Thread by =?Utf-8?B?YW5kaSByaWNrZW5iYWNo?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.