473,654 Members | 3,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(T reeView1.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 6235
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("user 32.dll", ExactSpelling = false, CharSet = CharSet.Auto)]
private static extern int GetWindowLong(I ntPtr hWnd, int nIndex);

....

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

/claes
"Jesper, Denmark" <Je***********@ discussions.mic rosoft.comwrote in message
news:72******** *************** ***********@mic rosoft.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(T reeView1.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
4690
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 need to specify html instead. The scrollbars do hide on Gecko browsers though, so there is definitely a disagreement among browser developers on how to implement scrollbars (as a side note, Gecko browsers with their notoriously bug-ridden...
6
2081
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 surrounded code with BeginUpdate/EndUpdate for both trees. The left tree doesn't flicker anymore, but the right one still does!! Even if I call BeginUpdate/EndUpdate on the right tree only, it still flickers. What's going on here? Is BeginUpdate working...
0
315
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? -------------------------------- From: SJ ----------------------- Posted by a user from .NET 247 (http://www.dotnet247.com/)
5
1700
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. What can I do about this? Thx.
0
893
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 get it to display the scrollbars when I resize my screen? I want to see those scrollbars also when I resize my screen so that I don't see the entire treeview.
17
2084
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 appreciated -- Dino Buljubasic Software Developer http://rivusglobal.com
0
1405
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 for vertical & horizontal scroll. Any idea how to manage this in VB.Net 2005? I have also tried to debug windows message through the WndProc() routine and when I move the scrollbars in the TreeView it does not generate WM_HSCROLL (276),...
1
3644
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
8372
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8814
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8706
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8475
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8591
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1592
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.