473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Detect scrollbars on treeview

Hi,

Is there a way to detect whenever scrollbars (the vertical) are shown on a
treeview
I need to know.

1) If scrollbars are visible after a rezise
2) If scrollbars are visible after change in content (e.g. nodes
collapsed/expanded, nodes added/deleted ). Any event to hook into?

I found something to solve (1) in VB6.0 (see below) but dont know how to
translate this into .net.

Dim wndStyle As Long

' Retrieve the window style of the control.
wndStyle = GetWindowLong(TreeView1.hwnd, GWL_STYLE)

' Test if the horizontal scroll bar style is present
' in the window style, indicating that a horizontal
' scroll bar is visible.
If (wndStyle And WS_HSCROLL) <0 Then
MsgBox "A horizontal scroll bar is visible."
Else
MsgBox "A horizontal scroll bar is NOT visible."
End If

' Test if the vertical scroll bar style is present
' in the window style, indicating that a vertical
' scroll bar is visible.
If (wndStyle And WS_VSCROLL) <0 Then
MsgBox "A vertical scroll bar is visible."
Else
MsgBox "A vertical scroll bar is NOT visible."
End If
Apr 5 '08 #1
1 6200
Here's the VB code translated to C#. I don't think there is any event for
when the scrollbar becomes visible so you probably need to check manually
after anything that might cause a scrollbar to show up.

private const int GWL_STYLE = -16;
private const int WS_VSCROLL = 0x00200000;
private const int WS_HSCROLL = 0x00100000;

[DllImport("user32.dll", ExactSpelling = false, CharSet = CharSet.Auto)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);

....

int style = GetWindowLong(treeView1.Handle, GWL_STYLE);
bool hasHScroll = ((style & WS_HSCROLL) != 0);
bool hasVScroll = ((style & WS_VSCROLL) != 0);

/claes
"Jesper, Denmark" <Je***********@discussions.microsoft.comwrote in message
news:72**********************************@microsof t.com...
Hi,

Is there a way to detect whenever scrollbars (the vertical) are shown on a
treeview
I need to know.

1) If scrollbars are visible after a rezise
2) If scrollbars are visible after change in content (e.g. nodes
collapsed/expanded, nodes added/deleted ). Any event to hook into?

I found something to solve (1) in VB6.0 (see below) but dont know how to
translate this into .net.

Dim wndStyle As Long

' Retrieve the window style of the control.
wndStyle = GetWindowLong(TreeView1.hwnd, GWL_STYLE)

' Test if the horizontal scroll bar style is present
' in the window style, indicating that a horizontal
' scroll bar is visible.
If (wndStyle And WS_HSCROLL) <0 Then
MsgBox "A horizontal scroll bar is visible."
Else
MsgBox "A horizontal scroll bar is NOT visible."
End If

' Test if the vertical scroll bar style is present
' in the window style, indicating that a vertical
' scroll bar is visible.
If (wndStyle And WS_VSCROLL) <0 Then
MsgBox "A vertical scroll bar is visible."
Else
MsgBox "A vertical scroll bar is NOT visible."
End If

Apr 7 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: Nobody | last post by:
Okay, you are all so smart in here. Answer me this: IE6 in standards mode doesn't seem to hide scrollbars on the body element (overflow:hide) Ain't this a quandary. I have it in my head that I...
6
by: Etienne | last post by:
Hi, I have a form containing 2 TreeViews. When I click on a button, items are transfered from the left tree to the right tree, which causes flickering. In order to remove such flickering, I...
0
by: SJ via .NET 247 | last post by:
For some reason, the scrollbars in my treeview component are not working. The scrollable property is set to True. I have the treeview in a panel. Does that make any difference? ...
5
by: Bart Schelkens | last post by:
Hi, i'm using the treeview from the Microsoft.Web.UI.Webcontrols.Treeview. It works fine. But my problem is that I don't get scrollbars if my treeview is too long or too wide for my frame....
0
by: Bart Schelkens | last post by:
Hi, I'm working with the Microsoft.Web.UI.WebControls.TreeView. I've put it in a <div></div> so that it would display scrollbars whenever the text was too wide or too high. Now how can I...
17
by: Dino M. Buljubasic | last post by:
I have a treeview and a checked list view controls one beside another. I want to make them work so that when I scroll down or up one of them the other does the same. Any help will be...
0
by: Sanjib Biswas | last post by:
Hi, I would like to know how to synchronize the vertical & horizontal scrollbars in 2 TreeView to move up & down, left & right synchronously. Noticed that TreeView does not have any scroll event...
1
by: Victor Rodriguez | last post by:
Is there a way that I can have a client side event like oncontextmenu="showfunction();" on each node? thanks, Victor
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.