Panel Height

P

Peter

Using .NET 1.1 Window Forms

I would like to place over 400 pictures on a panel control one after another
one so user can scroll through them, but each picture is up to 200 pixels in
height that's over 80,000 pixels in total, but panel control can go up to
only 32767 pixels. How can I allow a user to scroll through all of the 400
pictures?


Thanks


Peter
 
G

Guest

How about say, just a few pictures and a link that says "more..." and when
they click it, you delete the existing pictures and refresh it with the
puctures that follow the last one in the original list? You could even set up
two links "Next" and "Previous". Seems like that would be more user-friendly.
Peter
 
P

Peter

Peter Bromberg said:
How about say, just a few pictures and a link that says "more..." and when
they click it, you delete the existing pictures and refresh it with the
puctures that follow the last one in the original list? You could even set
up
two links "Next" and "Previous". Seems like that would be more
user-friendly.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com

Thanks for your help

This would be good suggestion for a web app, but I need something that will
allow user to scroll through many pictures. If I have 400 hundred pictures
and the user can see only 3 or 4 pictures on the screen at one time just
think how many times the user would have to click on the Next button to get
to the 400th picture.
 
L

Linda Liu [MSFT]

Hi Peter,

Since there's a limitation of Panel's Height, I recommend you to load a
picture once a time, for example by clicking on a "Previous" button or a
"Next" button.

We could place all the pictures in a folder and make use of the
GetFileSystemInfos method of the DirectoryInfo class to get the information
of all files in this folder, including the total count of these files and
each file's file name. Then we could navigate among all these files in our
program easily.

The following is a sample. It requires that you have set up a Windows
application and drag&drop a PictureBox, two Labels and two buttons onto the
form.

using System.IO;

public class Form1 : System.Windows.Forms.Form
{

FileSystemInfo[] infos;
int position = -1;

private void Form1_Load(object sender, System.EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo(@"C:\private\others\picures");
if (dir.Exists)
{
infos = dir.GetFileSystemInfos("*JPG");
this.label1.Text = infos.Length.ToString();
if (infos.Length > 0)
{
button2_Click(sender, e);
}
}
else
{
this.label1.Text = "0";
}
}
// click on button1 to navigate to the previous picture
private void button1_Click(object sender, System.EventArgs e)
{
if (position > 0)
{
position--;
this.pictureBox1.Image = Image.FromFile(infos[position].FullName);

}
this.label2.Text = (position + 1).ToString();
}
// click on button1 to navigate to the next picture
private void button2_Click(object sender, System.EventArgs e)
{
if (position < infos.Length - 1)
{
position++;
this.pictureBox1.Image = Image.FromFile(infos[position].FullName);
}
this.label2.Text = (position + 1).ToString();
}

Hope this helps.
If you don't think my workaround is suitable to your scenario, please feel
free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter

Linda Liu said:
Hi Peter,

Since there's a limitation of Panel's Height, I recommend you to load a
picture once a time, for example by clicking on a "Previous" button or a
"Next" button.

We could place all the pictures in a folder and make use of the
GetFileSystemInfos method of the DirectoryInfo class to get the
information
of all files in this folder, including the total count of these files and
each file's file name. Then we could navigate among all these files in our
program easily.

The following is a sample. It requires that you have set up a Windows
application and drag&drop a PictureBox, two Labels and two buttons onto
the
form.

using System.IO;

public class Form1 : System.Windows.Forms.Form
{

FileSystemInfo[] infos;
int position = -1;

private void Form1_Load(object sender, System.EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo(@"C:\private\others\picures");
if (dir.Exists)
{
infos = dir.GetFileSystemInfos("*JPG");
this.label1.Text = infos.Length.ToString();
if (infos.Length > 0)
{
button2_Click(sender, e);
}
}
else
{
this.label1.Text = "0";
}
}
// click on button1 to navigate to the previous picture
private void button1_Click(object sender, System.EventArgs e)
{
if (position > 0)
{
position--;
this.pictureBox1.Image = Image.FromFile(infos[position].FullName);

}
this.label2.Text = (position + 1).ToString();
}
// click on button1 to navigate to the next picture
private void button2_Click(object sender, System.EventArgs e)
{
if (position < infos.Length - 1)
{
position++;
this.pictureBox1.Image = Image.FromFile(infos[position].FullName);
}
this.label2.Text = (position + 1).ToString();
}

Hope this helps.
If you don't think my workaround is suitable to your scenario, please feel
free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Thank you for your help.

These pictures do not exist on the hard drive, they are created on the fly
and sit in memory only (but that's not important where these pictures
exist) - these pictures are snapshots of a graph and user needs to be able
to scroll through them quickly and select any one of them for closer
inspection, so Next and Previous button will not work, because that would
take way to long to scroll to the end of the pictures.
 
C

Chris Dunaway

Peter said:
Linda Liu said:
Hi Peter,

Since there's a limitation of Panel's Height, I recommend you to load a
picture once a time, for example by clicking on a "Previous" button or a
"Next" button.

We could place all the pictures in a folder and make use of the
GetFileSystemInfos method of the DirectoryInfo class to get the
information
of all files in this folder, including the total count of these files and
each file's file name. Then we could navigate among all these files in our
program easily.

The following is a sample. It requires that you have set up a Windows
application and drag&drop a PictureBox, two Labels and two buttons onto
the
form.

using System.IO;

public class Form1 : System.Windows.Forms.Form
{

FileSystemInfo[] infos;
int position = -1;

private void Form1_Load(object sender, System.EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo(@"C:\private\others\picures");
if (dir.Exists)
{
infos = dir.GetFileSystemInfos("*JPG");
this.label1.Text = infos.Length.ToString();
if (infos.Length > 0)
{
button2_Click(sender, e);
}
}
else
{
this.label1.Text = "0";
}
}
// click on button1 to navigate to the previous picture
private void button1_Click(object sender, System.EventArgs e)
{
if (position > 0)
{
position--;
this.pictureBox1.Image = Image.FromFile(infos[position].FullName);

}
this.label2.Text = (position + 1).ToString();
}
// click on button1 to navigate to the next picture
private void button2_Click(object sender, System.EventArgs e)
{
if (position < infos.Length - 1)
{
position++;
this.pictureBox1.Image = Image.FromFile(infos[position].FullName);
}
this.label2.Text = (position + 1).ToString();
}

Hope this helps.
If you don't think my workaround is suitable to your scenario, please feel
free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Thank you for your help.

These pictures do not exist on the hard drive, they are created on the fly
and sit in memory only (but that's not important where these pictures
exist) - these pictures are snapshots of a graph and user needs to be able
to scroll through them quickly and select any one of them for closer
inspection, so Next and Previous button will not work, because that would
take way to long to scroll to the end of the pictures.

Why don't you use a ListView since that is one of its purposes?
 
P

Peter

Chris Dunaway said:
Peter said:
Linda Liu said:
Hi Peter,

Since there's a limitation of Panel's Height, I recommend you to load a
picture once a time, for example by clicking on a "Previous" button or
a
"Next" button.

We could place all the pictures in a folder and make use of the
GetFileSystemInfos method of the DirectoryInfo class to get the
information
of all files in this folder, including the total count of these files
and
each file's file name. Then we could navigate among all these files in
our
program easily.

The following is a sample. It requires that you have set up a Windows
application and drag&drop a PictureBox, two Labels and two buttons onto
the
form.

using System.IO;

public class Form1 : System.Windows.Forms.Form
{

FileSystemInfo[] infos;
int position = -1;

private void Form1_Load(object sender, System.EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo(@"C:\private\others\picures");
if (dir.Exists)
{
infos = dir.GetFileSystemInfos("*JPG");
this.label1.Text = infos.Length.ToString();
if (infos.Length > 0)
{
button2_Click(sender, e);
}
}
else
{
this.label1.Text = "0";
}
}
// click on button1 to navigate to the previous picture
private void button1_Click(object sender, System.EventArgs e)
{
if (position > 0)
{
position--;
this.pictureBox1.Image =
Image.FromFile(infos[position].FullName);

}
this.label2.Text = (position + 1).ToString();
}
// click on button1 to navigate to the next picture
private void button2_Click(object sender, System.EventArgs e)
{
if (position < infos.Length - 1)
{
position++;
this.pictureBox1.Image =
Image.FromFile(infos[position].FullName);
}
this.label2.Text = (position + 1).ToString();
}

Hope this helps.
If you don't think my workaround is suitable to your scenario, please
feel
free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach
the
most efficient resolution. The offering is not appropriate for
situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are
best
handled working with a dedicated Microsoft Support Engineer by
contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Thank you for your help.

These pictures do not exist on the hard drive, they are created on the
fly
and sit in memory only (but that's not important where these pictures
exist) - these pictures are snapshots of a graph and user needs to be
able
to scroll through them quickly and select any one of them for closer
inspection, so Next and Previous button will not work, because that would
take way to long to scroll to the end of the pictures.

Why don't you use a ListView since that is one of its purposes?

Because I did not think of it.

Thanks I will try it.
 
P

Peter

Chris Dunaway said:
Peter said:
Linda Liu said:
Hi Peter,

Since there's a limitation of Panel's Height, I recommend you to load a
picture once a time, for example by clicking on a "Previous" button or
a
"Next" button.

We could place all the pictures in a folder and make use of the
GetFileSystemInfos method of the DirectoryInfo class to get the
information
of all files in this folder, including the total count of these files
and
each file's file name. Then we could navigate among all these files in
our
program easily.

The following is a sample. It requires that you have set up a Windows
application and drag&drop a PictureBox, two Labels and two buttons onto
the
form.

using System.IO;

public class Form1 : System.Windows.Forms.Form
{

FileSystemInfo[] infos;
int position = -1;

private void Form1_Load(object sender, System.EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo(@"C:\private\others\picures");
if (dir.Exists)
{
infos = dir.GetFileSystemInfos("*JPG");
this.label1.Text = infos.Length.ToString();
if (infos.Length > 0)
{
button2_Click(sender, e);
}
}
else
{
this.label1.Text = "0";
}
}
// click on button1 to navigate to the previous picture
private void button1_Click(object sender, System.EventArgs e)
{
if (position > 0)
{
position--;
this.pictureBox1.Image =
Image.FromFile(infos[position].FullName);

}
this.label2.Text = (position + 1).ToString();
}
// click on button1 to navigate to the next picture
private void button2_Click(object sender, System.EventArgs e)
{
if (position < infos.Length - 1)
{
position++;
this.pictureBox1.Image =
Image.FromFile(infos[position].FullName);
}
this.label2.Text = (position + 1).ToString();
}

Hope this helps.
If you don't think my workaround is suitable to your scenario, please
feel
free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach
the
most efficient resolution. The offering is not appropriate for
situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are
best
handled working with a dedicated Microsoft Support Engineer by
contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Thank you for your help.

These pictures do not exist on the hard drive, they are created on the
fly
and sit in memory only (but that's not important where these pictures
exist) - these pictures are snapshots of a graph and user needs to be
able
to scroll through them quickly and select any one of them for closer
inspection, so Next and Previous button will not work, because that would
take way to long to scroll to the end of the pictures.

Why don't you use a ListView since that is one of its purposes?

I don't think it will work for my program.

When a user clicks on the create graphs, the program creates all of the
place holders (which are picture boxes) and adds them to a Panel. All of
the pictures boxes are empty at that time, only when the paint event occurs
for the first time is when the graph is created and image of this graph is
taken and placed in the picture box, so when user scrolls to this picture
again the picture box only displays the picture of the graph the graph does
not have to be recreated, in addition a user can jump to any picture without
scrolling through all of them. So I don't know how would I create Image
list on the fly when the paint event occurs in the ListView. Plus ImageList
is limited to 256 pixels for width or height of a picture and the width will
be dependant on the current width of the control.
 
L

Linda Liu [MSFT]

Hi Peter,

Could you place more PictureBoxes on one row in the panel in order to
minimize the total height of all the PictureBoxes? If no, in my opinion,
using ListView is a good solution for your problem.
.....,only when the paint event occurs for the first time is when the
graph is created and image of this graph is taken and placed in the picture
box, ....

Would you tell me how you create the graph and place the image of this
graph in the picture box?
I don't know how would I create Image list on the fly when the paint
event occurs in the ListView.

I think you could create an image list and initialize it in the form's Load
event handler.
Plus ImageList is limited to 256 pixels for width or height of a picture
and the width will
be dependant on the current width of the control.

Yes, it is. But 256 pixels for height and width should be enough for the
images in your program. If the ListView's width is less than that of a
ListViewItem , the vertical scrollbar will appears. If you don't like it to
appear, you could enlarge the width of the ListView.

I look forward to your reply.


Sincerely,
Linda Liu
Microsoft Online Community Support
 
L

Linda Liu [MSFT]

Hi Peter,

How about your solving the problem?

If you need our further help, please feel free to tell me.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support
 
P

Peter

Linda Liu said:
Hi Peter,

Could you place more PictureBoxes on one row in the panel in order to
minimize the total height of all the PictureBoxes? If no, in my opinion,
using ListView is a good solution for your problem.

graph is created and image of this graph is taken and placed in the
picture
box, ....

Would you tell me how you create the graph and place the image of this
graph in the picture box?

event occurs in the ListView.

I think you could create an image list and initialize it in the form's
Load
event handler.

and the width will
be dependant on the current width of the control.

Yes, it is. But 256 pixels for height and width should be enough for the
images in your program. If the ListView's width is less than that of a
ListViewItem , the vertical scrollbar will appears. If you don't like it
to
appear, you could enlarge the width of the ListView.

I look forward to your reply.


Sincerely,
Linda Liu
Microsoft Online Community Support
Could you place more PictureBoxes on one row in the panel in order to
minimize the total height of all the PictureBoxes? If no, in my opinion,
using ListView is a good solution for your problem.

I can not place more than one picture per row, it would be confusing to a
user. The image size is to restricting for my purpose.
Would you tell me how you create the graph and place the image of this
graph in the picture box?

I am using ZedGraph control to create Graphs and images of those graphs
http://zedgraph.org/wiki/index.php?title=Main_Page
I think you could create an image list and initialize it in the form's
Load
event handler.

The graphs / images are created after the form loads, after user clicks on
the create graphs button
Yes, it is. But 256 pixels for height and width should be enough for the
images in your program. If the ListView's width is less than that of a
ListViewItem , the vertical scrollbar will appears. If you don't like it
to
appear, you could enlarge the width of the ListView.

256 pixels is not enough for width

I think I have found a solution for this, Vertical Scroll bar control,
scrolling is not as smooth as Panel scroll bar but it will work and it's
unlimited. With Vertical Scroll bar I can place only visible images on a
Panel and replace them as the user clicks on the scroll bar control.
 
L

Linda Liu [MSFT]

Hi Peter,

Thank you for your update. I understand your problem exactly now.

I had thought of the solution of using Vertical Scroll bar you put forward.
I also think that the disadvantages of this solution are that scrolling is
not as smooth as a panel's scroll bar and you need to add more code to
control which pictureboxes are displayed on the panel when the user clicks
on the Vertical Scroll bar.

As for the solution of using ListView, I think you could create all the
graphs/images after the user clicks on the create graphs button and
initialize the imagelist with all the images.

The advantages of this solution are that the scrolling is smooth and you
needn't add extra code to control which pictures are displayed when the
user clicks on ListView's scroll bar. However, the disadvantage of this
solution is that you have to create all the graphs/images after the user
clicks on the create graphs button, which may take more time than creating
the corresponding graph/image when a picturebox's Paint event occurs does.

So it seems both the two solutions have advantages and disadvantages. You
may select one of them according to your actual requirements.

Hope this helps.
If you have anything unclear, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support
 
L

Linda Liu [MSFT]

Hi Peter,

How about the problem now?

If you need our further assistance, please feel free to tell me.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support
 

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