i have setup a mdi parent form with 3 panles on it. one docked to the left , one docked to the right and the third docked as fill to sit inbetween the other two.
i want to display an image on the third panel and have it be scrollable if it is bigger than the panel size. i have tried to get just a single panel on a form, with the panels autoscroll set to true ( and also with the forms autoscroll set to true) and it doesnt want to work , i think i am missing a vital ingredient here.
Can anyone enlighten me ?
I have managed to get the scroll bars to appear in a test i did but when i adjust the scroll bars the image on the panel is getting corrupted. i am not doing anything in the OnPaint and it is not overridden so shouldnt the panle just 'move' within the scroll area. i understand it has to be redrawn, but there is nothing i have done to the redraw method (that i am aware of) that would make it alter the content on the panel.
Could some one provide any code that simply draws say arectangle on a panle and allows it to scroll in a form that is smaller than the panel size.
Are you drawing the image to the panel, or to a picturebox which gets added to the panel?.... Because if you're drawing it to the panel directly, then you need to go back and review how the AutoScroll property works.
AceInfinity's solution is essentially correct. Basically you draw to an object (e.g. a picturebox) that the panel contains and then change the location of that object (the coordinates of which are relative to the upper-left corner of the panel, not the form). GDI should take care of the rest of the drawing automagically, I think (been awhile since I did that). Note that you're not going to get amazing performance out of WinForms, but it may be adequate, depending on your purposes.
Best Regards,
BioPhysEngr http://blog.biophysengr.net
--
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
Put the image to the PictureBox, make the dimensions of the PictureBox no more and no less from the actual control's size, then place the PictureBox at (0, 0) within the panel, and make sure its AutoScroll property is set to true. The panel is a container for controls, so the picturebox actually needs to be added as a child control to the panel.
make the dimensions of the PictureBox no more and no less from the actual control's size
To clarify: you set the PictureBox to the size of the drawing canvas (image size), not to the size of the panel. Correct?
Best Regards,
BioPhysEngr http://blog.biophysengr.net
--
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
i was thinking along the lines of 3-5 independant bmp's all the same dimensions layered together. i would imagine it nees some sort of masking applid and if so is it built in or do i need to code it.
it has been 4+ years since i did any coding in c# and then i had only been looking at it for 6 months, so bear with me if i sound a little naive here.
layered together how? You need to define what you mean by 'layer' as mentioned before. In separate PictureBox's? In the same image within one PictureBox?
sorry should have been clearer, as i said between 3- 5 bmps merged down to a single bmp, transferred to the panel for the purpose of when the panel scrolls.
im just playing with ideas here, in advance, as im messing about with some lync 2010 code at the same time and the two are vastly different . i am still contemplating taking the whole thing into XNA.
as that fits more with some 3d stuff im doing in softimage,autodesk apps in general, not enough hours ina day though :S
For a PictureBox you could take the image out and modify it with GDI before assigning it back to the PictureBox quite easily to layer images into 1. Once you do that though, you can't just "remove" a layer, you have to save the previous image in memory or to the filesystem or something to have something to "revert" back to if that was the case.
This is what I did for my watermark program a while ago.
Bookmarks