C#面板列表 [英] C# List of Panels

查看:92
本文介绍了C#面板列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个面板,其中包含有关某项的详细信息(包括左侧的缩略图),然后将其添加到可滚动列表中.就像iPhone上的iTunes如何显示可用的应用程序列表一样.

I would like to create panels with detailed information regarding an item (including a thumbnail image on the left hand side) and then add these to a scrollable list. Much like how iTunes on the iPhone displays the lists of applications available.

我已经进行了一些搜索,但到目前为止仍找不到任何帮助.

I have done some searching but have thus far been unable to find any assistance.

任何人有任何想法或链接想要与我分享的示例.

Does anyone have any ideas or links to samples they would like to share with me.

预先感谢, 罗布

推荐答案

总而言之,以下内容在容器内创建了一系列面板,这些面板可使用垂直滚动条滚动进出视图.

您没有在标签中列出ASP.NET,因此我认为这是基于Windows表单的,而不是基于Web的.我会让你开始:

You did not list ASP.NET in your tags, so I assume this is Windows form-based, not web based. I'll get you started:

  1. 创建一个名为GrandChildPanel的面板.在其内部,在左侧放置一个图像框,并在图像旁边标记要显示的信息. 对于每个项目(例如iTunes歌曲),此面板都会重复.
  2. 将该面板放入另一个名为ChildPanel的等宽,等高面板中.
  3. 创建另一个名为ParentPanel的面板,并将其宽度设置为其他面板的大小,并为垂直滚动条留出足够的空间.将高度设置为等于您希望可滚动区域的高度.
  4. ChildPanel放在ParentPanel的右上角,然后将垂直滚动条添加到ParentPanel的最右边缘.设置滚动条的高度以占据ParentPanel的整个高度.
  5. 您可能想在ParentPanel上添加边框以显示其边界.
  6. 您可能还想在GrandChildPanel的底部添加一条1或2像素的线,以显示面板的结束位置.
  1. Create a panel called GrandChildPanel. Inside it, put an image box on the left side and labels with the information you want to display next to the image. This panel will be duplicated for every item (i.e., iTunes song).
  2. Put that panel inside another, equal-width, equal-height panel called ChildPanel.
  3. Create another panel called ParentPanel and set its width to the size of the other panels plus enough room for a vertical scroll bar. Set the height equal to however tall you want the scrollable area to be.
  4. Put ChildPanel in the top-right corner of ParentPanel and add a vertical scroll bar to the far right edge of ParentPanel. Set the scroll bar's height to takeup the entire height of ParentPanel.
  5. You probably want to add a border to ParentPanel to show its boundaries.
  6. You also probably want to add a 1 or 2 pixel line across the bottom of your GrandChildPanel to show where the panel ends.

这是设置.这是您对代码的要求:每次将项目添加到列表"(例如,iTunes列表中的每首歌曲)时,您都需要执行以下操作:

That's the setup. Here are the requirements for your code: Each time you 'add an item to the list' (e.g., every song in your iTunes list), you do the following:

  1. 克隆GrandChildPanel.
  2. 将克隆指定为ChildPanel的子代.
  3. 将克隆的Top设置为等于先前克隆的Top加上其Height.
  4. 设置ChildPanelHeight等于任何给定GrandChildPanel的高度乘以克隆数.
  5. 将滚动条的最大值设置为等于ChildPanel的高度.
  1. Clone the GrandChildPanel.
  2. Assign the clone to be a child of the ChildPanel.
  3. Set the clone's Top to be equal to the previous clone's Top plus its Height.
  4. Set ChildPanel's Height equal to any given GrandChildPanel's height multiplied by the number of clones.
  5. Set the scroll bar's maximum value to equal ChildPanel's height.

现在,要使此滚动成为可滚动状态,您要做的就是在垂直滚动条的滚动或更改事件上执行以下操作:将ChildPanelTop设置为等于垂直滚动条的值(位置")乘以-1.

Now, all you have to do to make this scrollable is perform the following on the scrolling or changing events of the vertical scroll bar: Set ChildPanel's Top to be equal to the verticle scroll bar's value ("position") multiplied by -1.

这篇关于C#面板列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆