.NET Framework - PictureBox on a Panel -- display scrollbars for large pics?
Asked By Rich P
12-Mar-10 03:20 PM
I have a PictureBox on a panel on a form. I have set the form's
autoscroll = true and I have set the panel's autoscroll = true. I cycle
through a list of pictures which display in the PictureBox, but when I
show a picture which is larger than the current panel size I need to
display scroll bars. But no scrollbars display. How do I make the
panel scrollbars display when I reach an oversized picture?
PictureBox sizemode = Normal, docking in panel is set to fill.
Thanks
Rich
*** Sent via Developersdex http://www.developersdex.com ***
Control
(1)
ThePictureBox
(1)
PictureBox
(1)
Igot
(1)
Yay
(1)
Crossthread
(1)
Scrollbars
(1)
Autoscroll
(1)
Rich P replied to Rich P
I tried setting the sizemode of the picturebox to "autosize", but then I
got an crossthread error message -- I am running the viewer in a while
loop and using a backgroundworker. Here is the error I get when I try
to use autosize on the picturebox sizemode
Cross-thread operation not valid: Control 'picImage' accessed from a
thread other than the thread it was created on.
In the error message it gave a link on how to work with cross threading
-- the article suggests to use a background work. I am already using a
background worker.
Rich
*** Sent via Developersdex http://www.developersdex.com ***
Rich P replied to Rich P
Yay! I got my dumb scrollbars! Here is what I did - I deleted the
original picturebox, deleted the containing panel, readded the panel and
dock = fill (under another panel, set autoscroll=true. Re-add a
picturebox, set sizemode to autosize, not docked, positioned at top left
cornver of containing panel. Now my oversized pictures activate the
scrollbars.
My next challenge will be dragging an oversized picture around inside
the panel.
Rich
*** Sent via Developersdex http://www.developersdex.com ***
Joe Cool replied to Rich P
I am curious, are the scrollbars part of the Panel control or the
PictureBox control?

to prepare a customcontrol consist of a label, one property LabelText- a text for label control and a window Form. When click on the label the window form should appear and property. Why do you need another one? It is simple enough to handle the Label control's Click event if you want to do something when the user clicks the mouse button while over the Label control. The Label class already has a TextChanged event, and this event will in fact be not you have an actual object instance? Also, are you trying to create a custom Control sub-class, or a UserControl? There is a difference between the two, and your post Form, but which you can place within an actual Form). Pete actually, a custom Label control is only an example. I work on custom control which is more complicate and the custom Label control is the way to see the possible solution. If you do not provide a realistic to follow the normal convention: declare an event corresponding to your custom property, when your control gets the Click event (for a custom control, you could just override OnClick()) show the
the other). Note that you can change the behavior if desired by setting the static Control.CheckForIllegalCrossThreadCalls property to "true". Then the exception will occur with or without the debugger attached which are always marshaled by Windows to the correct thread (the one that owns the control). But a) this implicit marshaling can cause hard-to-debug deadlock problems, and b) makes of the time (i.e. that 100% of the behavior is delegated to the Win32 control via window messages). Even for Forms controls that are in fact based on Win32 controls enhanced behaviors. And for Forms controls that are written mostly from scratch (they all inherit Control, and so all wind up having a window handle at some point???.NET Forms does Note that one major issue is that there are a number of members of the Control class that when accessed will implicitly cause the window handle for that Control instance to be created (creation of the window handle is generally deferred, not done when you accidentally cause the window handle to be created on the wrong thread, then your control just is not going to work correctly, because that is the thread where the messages for the control will be sent, and you probably will not have a message pump running on that
If it is not possible with ObjectDataSource, then I really do not know what this control is for. Then it is totally unusable for other then maybe one or two simplest seems for the code. If (!IsPostBack) ( go get the data and bind it to the control, using a binding method - - a first time load only - - if it is postback, then you do not do it. } This is not the control you are using a binding method of using a dataset to bind to the control. But the principle is the same for any control you are trying to bind the results of the SQL query to the control. You have two choices of using a dataset to bind to the control or using a collection to bind to a control by using a SQL datareader and populating the collection of objects to bind to the
Change the anchor property of a control. .NET Framework Hello. How can I capture the event, when changing the anchor property of the control ? I.e : myPanel.anchor = AnchorStyles.Left & AnchorStyles.Bottom . . . How can I know, when the Anchor property is changed (which event?) ? Thanks :) VB.NET Discussions EventArgs (1) Class (1) Control (1) AnchorChanged (1) PropertyGrid (1) Cor Ligthert (1) DockChanged (1) Resize (1) Am 12.06 when the property changes (like 'OnAnchorChanged'). I would handle the Resize event instead. Whether the control is anchored or not should not matter. If you set the property like above, you There is no specific event, but you may want to take a look at the control's 'Layout' event and 'OnLayout' method. - - M S Herfried K. Wagner M V P <URL them, stretch them, etc. For that I made two controls : First one is the "visual control" (that has no parent control, but "knows" how to draw the control (but is not paintable on screen). Second one is an "active control", which is a
could do something like this (an explicitly implemented event that delegates subscription to the underlying control): public event EventHandler LoadPortfolio { add { btnLoadPortfolio.Click + = value; } remove { btnPortfolio.Click - = value; } } ???and skip the what I can see. the The get / set should be in the IView for the control. The get / set for the control would be in the Interface of the form. At the UI form in its Interface, the get / set will point to a control on the form. If mpListview in the name of a control on the form, the get (mpListview) and the set (mpListview) = value will be used. The impListview is getting and sitting the control mpListview on the form. In the presenter. . . . . . . var ctrl = mview.impListview . . . . . the get mview.impListview folders in the UI project with folder reference being used. In this case, the button control would not be part of the presenter in the tutorial you are using, because it are using like listview, label, textbox are properties in the IView that point to a control on the form, and the presenter should be in control of populating and getting things