Scroll bars in image

A

Alberto

I'm trying to load an image in a PictureBox but I want the PictureBox has
always the same size and if the image is bigger, show a scrollBars.
How can I do it?
Thank you
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi Alberto

A simpler thing would be include the ImageBox inside a panel then you just
move the ImageBox and the panel will works like a windows, which is what you
want.

Cheers,
 
A

Alberto

It doesn't work. I have a pictureBox inside a panel control but when I load
a picture bigger than the PictureBox control, the bars doesn't appear.
I load the image in the paint event with this sentence:
e.graphics.Drawimage(Image, 0,0);

Thank you.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Why you load the image in the paint event?
You just load it once and that's all, after that all you would have to do
is reposition your picturebox.

below you will find a piece of code I just did for testing,
When I click on the button I load an image, the picturebox has SizeMode set
to autosize
the picturebox is inside the panel
//
// panel1
//
this.panel1.Controls.Add(this.pictureBox1);

This is what I do when the button is pressed, you have to change it to
refrect your need
private void button1_Click(object sender, System.EventArgs e)
{
Bitmap b = new Bitmap( @"c:\imagenlogin.jpg" );
pictureBox1.Image = b;
}

I added a scrollbar next to the panel, this is the code for the handler
private void vScrollBar1_Scroll(object sender,
System.Windows.Forms.ScrollEventArgs e)
{
pictureBox1.Top = -e.NewValue;
}


It does work as intended, if you still need help let me know and I will post
the complete code for the page


Cheers,
 
A

Alberto

It works very well now.
I'd like now do a zoom in the image and I was trying the SetResolution
method of the BitMap class
with this code:
myBitMap.SetResolution(myBitMap.Width*2, myBitMap.Height*2);

pic.Image = myBitMap;

But it doesn't work. I suppose I'm not using it in a proper way but I don't
know how to do a zoom.

Thank you very very much.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi Alberto,


Unfortunally I do not know for sure how to do it :(
You will have to google for it or post this question back in the
windowsform NG

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
 
A

Alberto

Thanks anyway.

Ignacio Machin ( .NET/ C# MVP ) said:
Hi Alberto,


Unfortunally I do not know for sure how to do it :(
You will have to google for it or post this question back in the
windowsform NG

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation




to
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top