473,781 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

adding scrollbars in C# Forms 2.0 - howto here

Scrollbars scroll bars adding scrollbars in C# Forms 2.0 scrollbars
don't work won't work how to add scrollbar in C#

Here is how to add a scrollbar to a form. It's not in any book. For
future reference only, no question being asked.

This works for forms, as well as "panels".

Below example is for forms, but will also work in a panel.

RL

public MyForm()
{

InitializeCompo nent();
myRect = new Rectangle(150,1 50,10,5000); //this is what
you want to draw, but it's really long and won't fit in a normal
window, so add a scrollbar

//first, you *must* add a dummy control to your form (mandatory).
Here called button b
Button b = new Button();
b.Location = new Point(0, 5000); //place it at the lower
left corner
b.Text = "dummy_butt on"; //call it something (you can also
make it invisible but that's optional)

this.Controls.A dd(b); //add to form
}

//now make sure you check the Properties checkbox for the form (MyForm
here) for "AutoScroll " to "true" in the Visual Studio Designer
(Wizard), which will add a line in the machine generated constructor

// now you have scrollbars added automatically.

//these below lines are to prevent flicker (also check DoubleBuffer
property in the form)

private void MyForm_Scroll(o bject sender, ScrollEventArgs e)
{
this.Invalidate (true);
}

private void MyForm_VisibleC hanged(object sender, EventArgs e)
{
this.Invalidate (true);
}

private void MyForm_Resize(o bject sender, EventArgs e)
{
this.Invalidate (true);
// more here: http://www.bobpowell.net/understanding_autoscroll.htm //
if you want your graphic to 'move' with the scrollbar--note how the
matrix is used --I find this is nice but optional
Oct 31 '08 #1
1 21002
raylopez99 wrote:
// more here: http://www.bobpowell.net/understanding_autoscroll.htm //
if you want your graphic to 'move' with the scrollbar--note how the
matrix is used --I find this is nice but optional
Update: turns out bob powell's suggestion here is more than just
optional--it really does make your scroll bars work. So in addtion to
the above I would add the Matrix transform suggested in Powell's site.
Nov 1 '08 #2

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

Similar topics

1
2863
by: Martin | last post by:
This is probably a very easy one but I just can't put my finger on the communicating events name:- I have a MDIform with a couple of child forms. The child forms scroll vertically at run time using the automatically supplied scrollbars of the MDIform. When scrolling , or immediately after scrolling, the child forms I want a procedure to be called. How do I do this??. I have tried the MDIform_MouseUp event and this works correctly when...
6
3380
by: CJM | last post by:
I've been trying to tweak the design of a few pages in one of my ASP apps... I'm making sure that the layout is reasonable for resolutions between 800x600 and 1024x768. Since it's almost all forms (rather than text) it takes a bit of extra effort to find the right balance. At the higher resolution, everything is fine. When I reduce the IE window to 800x600 (via bookmarklet), I'm getting both horizontal and vertical scrollbars; the...
1
10487
by: Gerben van Loon | last post by:
Hi, I've drawn my own control using GDI+. But the control is bigger than a normal form could display, so I want to add scrollbars. Saw somewhere that you have to inherit from "System.Windows.Forms.ScrollableControl". So I did that, and the scrollbars are displayed very nice. But when you actually start scrolling the graphics I've drawn with GDI+ are completely disturbed. Someone know what I'm doing wrong? Is there another way to add...
1
17532
by: Kristof Nachtergaele | last post by:
Hi, I'm looking for something, which acts as a container, that I can drop onto my form and which has a size that is bigger than the visible part, the invisible pazrt being scrollable to with scrollbars. Actually it boils down to a form in a form in a certain way, does anyone have any idea if there is allready such a component around somewhere, and if not from which class to start to create it? thx,
17
2093
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
4
1742
by: scorpion53061 | last post by:
I have a datagrid that is switches between 2 different datasources. I set the anchor properties of my datagrid to for bottom, top, left , right. My form is set ot maximize on open. If the user resizes the form, the scrollbars that should be visible on the datagrid are not. Occasionally the scrollbars disappear when the form is maximized when
5
11121
by: Christopher Kurtis Koeber | last post by:
Dear All, This may sound like an elementary question but how do you implement scrollbars for the Picturebox control. Do I have to create my own code to do this or is there some property that I can set? Thank you very much for your time and consideration in this matter! Christopher Koeber
0
1202
by: Dan Sikorsky | last post by:
I have labels and associated multiline textboxes on a panel that's disabled for the purpose of presenting lengthy readonly comments. Using this method, the textbox scrollbars don't work; the user must click in the textbox and 'arrow down' to see the lengthy comment. How can I get the scrollbars to work? Enabling the panel, and setting the textbox readonly property works, but I have to manage the forecolor and backcolor of the textbox...
2
2225
by: RMCEU1 | last post by:
I can't imagine I'm the first to experience this, but Google searches in all access newsgroups have produced nothing. Access 2003/WinXP After creating an MDE for my app, not only are there no scrollbars for the MDI (main Access "container" window), there are also no scrollbars for the forms I've created - even though I've set scrollbars to "Both" in each form's property window. When opening the MDB, regardless of screen resolution,...
0
9639
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
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10143
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...
0
9939
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
8964
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7486
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2870
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.