473,385 Members | 2,013 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,385 software developers and data experts.

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()
{

InitializeComponent();
myRect = new Rectangle(150,150,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_button"; //call it something (you can also
make it invisible but that's optional)

this.Controls.Add(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(object sender, ScrollEventArgs e)
{
this.Invalidate(true);
}

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

private void MyForm_Resize(object 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 20975
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
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...
6
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...
1
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...
1
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...
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...
4
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...
5
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...
0
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...
2
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...

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.