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.
PS. here's code snip of what I'm trying to do....
Private components As System.Componen tModel.IContain er
Friend WithEvents Panel1 As System.Windows. Forms.Panel
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()
Me.Panel1 = New System.Windows. Forms.Panel
Me.SuspendLayou t()
'
'Panel1
'
Me.Panel1.Ancho r = CType((((System .Windows.Forms. AnchorStyles.To p Or
System.Windows. Forms.AnchorSty les.Bottom) _
Or System.Windows. Forms.AnchorSty les.Left) _
Or System.Windows. Forms.AnchorSty les.Right),
System.Windows. Forms.AnchorSty les)
Me.Panel1.AutoS croll = True
Me.Panel1.BackC olor = System.Drawing. Color.White
Me.Panel1.Borde rStyle = System.Windows. Forms.BorderSty le.Fixed3D
Me.Panel1.Locat ion = New System.Drawing. Point(112, 56)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing. Size(472, 344)
Me.Panel1.TabIn dex = 0
'
'Preview
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(592, 413)
Me.Controls.Add (Me.Panel1)
Me.Name = "Preview"
Me.Text = "Preview"
Me.ResumeLayout (False)
End Sub
Private Sub DrawIt(ByVal g As Graphics)
g.DrawLine(New Pen(Color.Black ), 2, 2, 500, 400)
End Sub
Private Sub Panel1_Paint(By Val sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs) Handles Panel1.Paint
DrawIt(e.Graphi cs)
End Sub 5 22271
You should use AutoScrollMinSi ze and AutoScrollMargi n to let the control
know that your area has a certain size, whether it has other controls in it
or not.
To redraw the line, you should capture the OnAutoScroll event (I don't
remember the exact name, but it's something like that) and call
[MyControl].Invalidate() or even [MyForm].Invalidate(tru e)...
With this, .Net calls the Paint event for your MyControl or your MyForm
(invalidating all children controls).
I'm not sure it's not called automatically if you set the drawing styles of
your control... Try your code with the AutoScrollMinSi ze and Margin set, and
do the scrolling to see if your line gets redrawn...
Hope this helps...
VBen.
"Rob T" <RT*********@DO NTwalchemSPAM.c om> escribió en el mensaje
news:Od******** ******@TK2MSFTN GP15.phx.gbl... 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.
PS. here's code snip of what I'm trying to do....
Private components As System.Componen tModel.IContain er Friend WithEvents Panel1 As System.Windows. Forms.Panel
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent() Me.Panel1 = New System.Windows. Forms.Panel
Me.SuspendLayou t()
'
'Panel1
'
Me.Panel1.Ancho r = CType((((System .Windows.Forms. AnchorStyles.To p Or System.Windows. Forms.AnchorSty les.Bottom) _
Or System.Windows. Forms.AnchorSty les.Left) _
Or System.Windows. Forms.AnchorSty les.Right), System.Windows. Forms.AnchorSty les)
Me.Panel1.AutoS croll = True
Me.Panel1.BackC olor = System.Drawing. Color.White
Me.Panel1.Borde rStyle = System.Windows. Forms.BorderSty le.Fixed3D
Me.Panel1.Locat ion = New System.Drawing. Point(112, 56)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing. Size(472, 344)
Me.Panel1.TabIn dex = 0
'
'Preview
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(592, 413)
Me.Controls.Add (Me.Panel1)
Me.Name = "Preview"
Me.Text = "Preview"
Me.ResumeLayout (False)
End Sub
Private Sub DrawIt(ByVal g As Graphics)
g.DrawLine(New Pen(Color.Black ), 2, 2, 500, 400)
End Sub
Private Sub Panel1_Paint(By Val sender As Object, ByVal e As System.Windows. Forms.PaintEven tArgs) Handles Panel1.Paint
DrawIt(e.Graphi cs)
End Sub
See the article in Windows Forms Tips and Tricks that explains autoscroll
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Rob T" <RT*********@DO NTwalchemSPAM.c om> wrote in message
news:Od******** ******@TK2MSFTN GP15.phx.gbl... 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.
PS. here's code snip of what I'm trying to do....
Private components As System.Componen tModel.IContain er Friend WithEvents Panel1 As System.Windows. Forms.Panel
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()
Me.Panel1 = New System.Windows. Forms.Panel
Me.SuspendLayou t()
'
'Panel1
'
Me.Panel1.Ancho r = CType((((System .Windows.Forms. AnchorStyles.To p Or System.Windows. Forms.AnchorSty les.Bottom) _
Or System.Windows. Forms.AnchorSty les.Left) _
Or System.Windows. Forms.AnchorSty les.Right), System.Windows. Forms.AnchorSty les)
Me.Panel1.AutoS croll = True
Me.Panel1.BackC olor = System.Drawing. Color.White
Me.Panel1.Borde rStyle = System.Windows. Forms.BorderSty le.Fixed3D
Me.Panel1.Locat ion = New System.Drawing. Point(112, 56)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing. Size(472, 344)
Me.Panel1.TabIn dex = 0
'
'Preview
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(592, 413)
Me.Controls.Add (Me.Panel1)
Me.Name = "Preview"
Me.Text = "Preview"
Me.ResumeLayout (False)
End Sub
Private Sub DrawIt(ByVal g As Graphics)
g.DrawLine(New Pen(Color.Black ), 2, 2, 500, 400)
End Sub
Private Sub Panel1_Paint(By Val sender As Object, ByVal e As System.Windows. Forms.PaintEven tArgs) Handles Panel1.Paint
DrawIt(e.Graphi cs)
End Sub
Thanks for the tip on using the matrix...works great!
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. See the article in Windows Forms Tips and Tricks that explains autoscroll
-- Bob Powell [MVP] Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article.
"Rob T" <RT*********@DO NTwalchemSPAM.c om> wrote in message news:Od******** ******@TK2MSFTN GP15.phx.gbl... 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.
PS. here's code snip of what I'm trying to do....
Private components As System.Componen tModel.IContain er Friend WithEvents Panel1 As System.Windows. Forms.Panel
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()
Me.Panel1 = New System.Windows. Forms.Panel
Me.SuspendLayou t()
'
'Panel1
'
Me.Panel1.Ancho r = CType((((System .Windows.Forms. AnchorStyles.To p Or System.Windows. Forms.AnchorSty les.Bottom) _
Or System.Windows. Forms.AnchorSty les.Left) _
Or System.Windows. Forms.AnchorSty les.Right), System.Windows. Forms.AnchorSty les)
Me.Panel1.AutoS croll = True
Me.Panel1.BackC olor = System.Drawing. Color.White
Me.Panel1.Borde rStyle = System.Windows. Forms.BorderSty le.Fixed3D
Me.Panel1.Locat ion = New System.Drawing. Point(112, 56)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing. Size(472, 344)
Me.Panel1.TabIn dex = 0
'
'Preview
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(592, 413)
Me.Controls.Add (Me.Panel1)
Me.Name = "Preview"
Me.Text = "Preview"
Me.ResumeLayout (False)
End Sub
Private Sub DrawIt(ByVal g As Graphics)
g.DrawLine(New Pen(Color.Black ), 2, 2, 500, 400)
End Sub
Private Sub Panel1_Paint(By Val sender As Object, ByVal e As System.Windows. Forms.PaintEven tArgs) Handles Panel1.Paint
DrawIt(e.Graphi cs)
End Sub
Thanks. That worked great. I couln't find any events that were like
OnAutoScroll... but when I scrolled, it refreshed on it's own anyway.
Perhaps it triggers the paint event automatically.. .
"VBen" <bm******@compu caremexico.com> wrote in message
news:Ow******** ******@TK2MSFTN GP15.phx.gbl... You should use AutoScrollMinSi ze and AutoScrollMargi n to let the control know that your area has a certain size, whether it has other controls in it or not. To redraw the line, you should capture the OnAutoScroll event (I don't remember the exact name, but it's something like that) and call [MyControl].Invalidate() or even [MyForm].Invalidate(tru e)... With this, .Net calls the Paint event for your MyControl or your MyForm (invalidating all children controls). I'm not sure it's not called automatically if you set the drawing styles of your control... Try your code with the AutoScrollMinSi ze and Margin set, and do the scrolling to see if your line gets redrawn... Hope this helps... VBen.
"Rob T" <RT*********@DO NTwalchemSPAM.c om> escribió en el mensaje news:Od******** ******@TK2MSFTN GP15.phx.gbl... 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.
PS. here's code snip of what I'm trying to do....
Private components As System.Componen tModel.IContain er Friend WithEvents Panel1 As System.Windows. Forms.Panel
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent() Me.Panel1 = New System.Windows. Forms.Panel
Me.SuspendLayou t()
'
'Panel1
'
Me.Panel1.Ancho r = CType((((System .Windows.Forms. AnchorStyles.To p Or System.Windows. Forms.AnchorSty les.Bottom) _
Or System.Windows. Forms.AnchorSty les.Left) _
Or System.Windows. Forms.AnchorSty les.Right), System.Windows. Forms.AnchorSty les)
Me.Panel1.AutoS croll = True
Me.Panel1.BackC olor = System.Drawing. Color.White
Me.Panel1.Borde rStyle = System.Windows. Forms.BorderSty le.Fixed3D
Me.Panel1.Locat ion = New System.Drawing. Point(112, 56)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing. Size(472, 344)
Me.Panel1.TabIn dex = 0
'
'Preview
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(592, 413)
Me.Controls.Add (Me.Panel1)
Me.Name = "Preview"
Me.Text = "Preview"
Me.ResumeLayout (False)
End Sub
Private Sub DrawIt(ByVal g As Graphics)
g.DrawLine(New Pen(Color.Black ), 2, 2, 500, 400)
End Sub
Private Sub Panel1_Paint(By Val sender As Object, ByVal e As System.Windows. Forms.PaintEven tArgs) Handles Panel1.Paint
DrawIt(e.Graphi cs)
End Sub
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Amrit |
last post by:
Hi
Can anyone help me? I would really appreciate
I am trying to scroll Groupboxes inside the panel when i hold panel's scroll bar and drag up and down. Such as Internet explorer where you can hold the scroll bar and drag up down which causes the material to move at the same time up and down
Thank
Amrit.
|
by: Nathan |
last post by:
I need a panel with only a vertical or only a horizontal scroll bar. Is
there a way to do that?
Nathan
|
by: Al |
last post by:
Hi,
I am using large PictureBox inside a Panel, user can write on the PictureBox
(it is actually InkPicture) but the problem that I have is regarding the
Auto scrolling of the panel.. For example if a user scroll down and start
clicking or any other mouse/pen activity on the PictureBox, the Panel will
scroll back up. This happened only the...
|
by: Sam |
last post by:
Hi,
I would like to reproduce the same control as in Visual Studio for the
propery editor or the message feedback window. That is, a scrolling
panel that would appear when the mouse is over one of the side of the
main form. There should be the possibility to anchor it as well. How
can I do that ?
Thx
|
by: John |
last post by:
Can I use the Atlas controls to create a scrolling panel in a webform?
Basically I want a master page that defines 90% of the screen height to be a
workspace, with 5% top and bottom for other controls.
The 90% should scroll (up and down) without effecting the top and bottom
placeholders. Frames would be the obvious way, but no way for...
| |
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...
|
by: shahoo |
last post by:
Hi,
I am trying to add some controls (say buttons) to a panel. At some
stage the controls are
too much to be show on the panel, so I set the Autoscroll property of
the panel to true.
But my problem is that I don't want the user to use the scroll bars of
the panel, I want to
add two custom buttons to scroll the panel. When I set the Visible...
|
by: mike |
last post by:
Hi guys,
I have a windows form and on load event I dynamically created a panel
and dynamically create/add pictureboxes to panel and added a panel to
the form with docking with fill. I am basically creating a thumb nails
view for multiple pictures. Two question.
1I have set the panel's autoscroll to true, so I can actually see
and scroll...
|
by: mateusz.zajakala |
last post by:
Hi,
I have panel (with autoscroll property) on which I'm dynamicaly adding
of controls. When I want to scroll my panel using scrollbars it
freezes all the controls added on that panel, makes them nasty
stretch.
Is there any way to prevent that stretch, and scroll panel smoothly?
I tried to add DoEvents() to Scroll event of my panel,...
|
by: luker |
last post by:
Hi Experts,
I'm trying to create a panel-derived class with Autoscroll = true that scrolls horizontally when using <Shift>+Mousewheel. Sounds like a straight forward task, doesn't it?
I tried this code:protected override void OnMouseWheel(MouseEventArgs e)
{
if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
{
// Get...
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |