473,624 Members | 2,394 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Panel with scrollbars

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,
Kristof
Nov 15 '05 #1
1 17519
I haven't finished it yet, but I was banging one out for something.
Here's the code thus far. You're responsible for drawing your controls
on, and resizing, DataPane yourself. The container should do the rest.

//<CODE>
using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Drawing;
using System.Data;
using System.Windows. Forms;

namespace ScrollPanel {

public delegate void ResetClickHandl er( object sender, EventArgs e );

/// <summary>
/// Summary description for UserControl1.
/// </summary>
public class ScrollPane : System.Windows. Forms.UserContr ol {

public event ResetClickHandl er ResetClicked;

public enum ResetButtonBeha viors {
Normal=0,
Hidden=1,
Disabled=2
}

private const int SCROLL_THICKNES S = 16;
private const int EDGE_PADDING = 2;

private ResetButtonBeha viors pResetButtonBeh avior =
ResetButtonBeha viors.Normal;

private System.Windows. Forms.PictureBo x pbContainer;
private System.Windows. Forms.Button btnReset;
private System.Windows. Forms.VScrollBa r vScroller;
private System.Windows. Forms.HScrollBa r hScroller;
private System.Windows. Forms.PictureBo x ViewPort;
private System.Windows. Forms.PictureBo x DataPane;

/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.Containe r components = null;

public ScrollPane() {
// This call is required by the Windows.Forms Form Designer.
InitializeCompo nent();

// TODO: Add any initialization after the InitForm call

}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing ) {
if( disposing ) {
if( components != null )
components.Disp ose();
}
base.Dispose( disposing );
}

#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.pbContaine r = new System.Windows. Forms.PictureBo x();
this.btnReset = new System.Windows. Forms.Button();
this.vScroller = new System.Windows. Forms.VScrollBa r();
this.hScroller = new System.Windows. Forms.HScrollBa r();
this.ViewPort = new System.Windows. Forms.PictureBo x();
this.DataPane = new System.Windows. Forms.PictureBo x();
this.SuspendLay out();
//
// pbContainer
//
this.pbContaine r.BorderStyle =
System.Windows. Forms.BorderSty le.Fixed3D;
this.pbContaine r.Name = "pbContaine r";
this.pbContaine r.Size = new System.Drawing. Size(448, 448);
this.pbContaine r.TabIndex = 0;
this.pbContaine r.TabStop = false;
//
// btnReset
//
this.btnReset.L ocation = new System.Drawing. Point(430, 430);
this.btnReset.N ame = "btnReset";
this.btnReset.S ize = new System.Drawing. Size(16, 16);
this.btnReset.T abIndex = 7;
this.btnReset.T abStop = false;
this.btnReset.T ext = ".";
this.btnReset.C lick += new
System.EventHan dler(this.btnRe set_Click);
//
// vScroller
//
this.vScroller. LargeChange = 100;
this.vScroller. Location = new System.Drawing. Point(429, 4);
this.vScroller. Name = "vScroller" ;
this.vScroller. Size = new System.Drawing. Size(16, 424);
this.vScroller. TabIndex = 6;
this.vScroller. Scroll += new
System.Windows. Forms.ScrollEve ntHandler(this. vScroller_Scrol l);
//
// hScroller
//
this.hScroller. LargeChange = 100;
this.hScroller. Location = new System.Drawing. Point(5, 430);
this.hScroller. Name = "hScroller" ;
this.hScroller. Size = new System.Drawing. Size(423, 16);
this.hScroller. TabIndex = 5;
this.hScroller. Scroll += new
System.Windows. Forms.ScrollEve ntHandler(this. hScroller_Scrol l);
//
// ViewPort
//
this.ViewPort.B orderStyle =
System.Windows. Forms.BorderSty le.Fixed3D;
this.ViewPort.L ocation = new System.Drawing. Point(2, 2);
this.ViewPort.N ame = "ViewPort";
this.ViewPort.S ize = new System.Drawing. Size(418, 422);
this.ViewPort.T abIndex = 8;
this.ViewPort.T abStop = false;
//
// DataPane
//
this.DataPane.L ocation = new System.Drawing. Point(4, 4);
this.DataPane.N ame = "DataPane";
this.DataPane.S ize = new System.Drawing. Size(52, 56);
this.DataPane.T abIndex = 9;
this.DataPane.T abStop = false;
//
// ScrollPane
//
this.Controls.A ddRange(new System.Windows. Forms.Control[] {
this.DataPane,
this.ViewPort,
this.btnReset,
this.vScroller,
this.hScroller,
this.pbContaine r});
this.Name = "ScrollPane ";
this.Size = new System.Drawing. Size(450, 450);
this.Resize += new System.EventHan dler(this.Scrol lPane_Resize);
this.ResumeLayo ut(false);

}
#endregion

private void ScrollPane_Resi ze(object sender, System.EventArg s e) {

DataPane.Parent = ViewPort;

pbContainer.Loc ation = new Point( 0, 0 );
pbContainer.Siz e = new Size( this.Width, this.Height );

hScroller.Locat ion = new Point( EDGE_PADDING, pbContainer.Hei ght -
(EDGE_PADDING + SCROLL_THICKNES S) );
hScroller.Size = new Size( pbContainer.Wid th - ( (EDGE_PADDING*2 ) +
SCROLL_THICKNES S), SCROLL_THICKNES S );

vScroller.Locat ion = new Point( pbContainer.Wid th - (EDGE_PADDING +
SCROLL_THICKNES S), EDGE_PADDING );
vScroller.Size = new Size( SCROLL_THICKNES S, pbContainer.Hei ght - (
(EDGE_PADDING*2 ) + SCROLL_THICKNES S ) );

btnReset.Size = new Size( SCROLL_THICKNES S, SCROLL_THICKNES S );
btnReset.Locati on = new Point( pbContainer.Wid th - (EDGE_PADDING +
SCROLL_THICKNES S), pbContainer.Hei ght - (EDGE_PADDING +
SCROLL_THICKNES S) );

ViewPort.Parent = pbContainer;
ViewPort.Locati on = new Point( 0, 0 );
ViewPort.Size = new Size( pbContainer.Wid th - ((EDGE_PADDING* 2) +
SCROLL_THICKNES S), pbContainer.Hei ght - ((EDGE_PADDING* 2) +
SCROLL_THICKNES S ) );

CalculateScroll bars();
}

private void CalculateScroll bars(){
hScroller.Enabl ed = ( DataPane.Width > ViewPort.Width );
if( hScroller.Enabl ed ){
hScroller.Maxim um = (DataPane.Width - ViewPort.Width) +120;
hScroller.Minim um = 0;
}

vScroller.Enabl ed = ( DataPane.Height > ViewPort.Height );
if( vScroller.Enabl ed ){
vScroller.Maxim um = (DataPane.Heigh t - ViewPort.Height )+120;
vScroller.Minim um = 0;
}
}

private void SetButtonBehavi or( ResetButtonBeha viors behavior ){
switch( behavior ){
case ResetButtonBeha viors.Normal:
btnReset.Enable d = true;
btnReset.Visibl e = true;
break;
case ResetButtonBeha viors.Hidden:
btnReset.Visibl e = false;
btnReset.Enable d = true;
break;
case ResetButtonBeha viors.Disabled:
btnReset.Visibl e = true;
btnReset.Enable d = false;
break;
}
}

private void btnReset_Click( object sender, System.EventArg s e) {
if( ResetClicked != null ){
ResetClicked( btnReset, e );
}
}

private void vScroller_Scrol l(object sender,
System.Windows. Forms.ScrollEve ntArgs e) {
int val = vScroller.Value ;
DataPane.Top = (-1 * val)+1;
}

private void hScroller_Scrol l(object sender,
System.Windows. Forms.ScrollEve ntArgs e) {
int val = hScroller.Value ;
DataPane.Left = (-1 * val)+1;
}

public ResetButtonBeha viors ResetButtonBeha vior{
get{
return pResetButtonBeh avior;
}
set{
pResetButtonBeh avior = value;
SetButtonBehavi or( pResetButtonBeh avior );
}
}

public PictureBox DataPanel {
get{
return this.DataPane;
}
}

public Size DataPaneSize {
get{
return DataPane.Size;
}
set{
DataPane.Size = value;
CalculateScroll bars();
}
}

}
}
//</CODE>

"Kristof Nachtergaele" <ik**@nie.com > wrote in message news:<3f******* *************** *@reader1.news. skynet.be>...
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,
Kristof

Nov 15 '05 #2

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

Similar topics

3
4082
by: Raymond Dynowski | last post by:
How do you force a panel to scroll in code. I have a large picture box inside my panel. I would like the panel to default to the centre of the screen, rather than the scrollbars showing the top left corner Thanks Ray
2
6013
by: Sascha Schmidt | last post by:
Hello ! I'm trying to combine an external (not part of the panel) vertical scrollbar (VScrollBar) with a panel in order to scroll the content of the panel vertically using the external VScrollbar. I can't set the "AutoScroll"-property to true and then use the generated scrollbars inside the panel, because i have to use this external scrollbar which is a modified/customized scrollbar, and doesn't look like a standard scrollbar.
0
1325
by: Tom | last post by:
I have a panel that is set for autoscrolling, however I -DON'T- want the scrollbars to show up. Do anyone know of any way to make a panel autoscroll and yet have no scrollbars? I know that is an odd request but trust me, it is what I need to do in this screwyapplications case :-) Basically, I am keeping this panel synced with another panel (that the user does scroll) and therefore need to scroll the panel programatically. Thanks. Tom
5
22282
by: Rob T | last post by:
To keep my example simple, let's say I have a windows application form with a panel in it. For this example, I want to draw a single line in the panel, which is larger than the size of the panel. Is there a way to get the scrollbars to show up? Also....If I were to put a control (like a button) into the panel, the scrollbars are there...but my line doesn't redraw properly. How should I be doing this? Thanks.
0
1194
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...
0
1251
by: Elroyskimms | last post by:
I have a fixed witdth panel control with horizontal scrollbars. In it, I load a table and in each table cell is an instance of a user control that I created it. In theory, 3-5 of these controls are visible in the panel at any given time, and the scrollbars can be used to see anything that is offscreen (overflowed). This works as expected in IE 6+. However, in Safari, the scrollbars do not even show up, leaving only the 3-5 controls...
1
2935
by: mrabie | last post by:
Hi All, I know this has been discussed before but i can't really find an answer to what i want to do. I am developing an application for touchscreen using C#. It's going to be a fullscreen application somewhat like a new windows shell. I want the user to scroll up/down the objects currently viewed on the display using finger gestures (e.g. like HTC TouchFlo where when moving your finger from the top to the buttom of the screen the...
2
9437
by: ATR2000 | last post by:
I have setup a Panel to have a width of 100% so that it will adjust to users screensize. Within the panel I have a table. Unfortunately the table holds a lot of data and exceeds the size of the screen. The panel has a height of 350px and the scrollbar is set to auto so that both scrollbars appear when needed. What is happening is that due to the table exceeding the width of the screen the panel is also enlarging its width larger than...
5
4719
by: kulabhishek | last post by:
Hi all, I am using panel with autoscroll = true in C# I have added dataGridView control inside panel. When the height and width of dataGridView increases and becomes more than panel size, scrollbars of panel are enabled. When i scroll using any scrollbar and click on the dataGridView which is inside panel, the position of the scrolled scrollbar changes automatically and scrollbars goes to start position.
2
4276
by: kulabhishek | last post by:
Hello all. I have developed one user control "Grid" in C# and I am using it in another user control inside one panel. The AutoScroll property for the panel is enabled. When the height or width of "Grid" increases and becomes more than panel size, scrollbars of panel are enabled. When I scroll using any scrollbar and click on the "Grid" which is inside panel, the position of the scrolled scrollbar changes automatically and...
0
8240
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
8175
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
8680
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...
1
8336
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
8482
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
4082
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
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2610
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
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.