简体   繁体   English

C#面板列表

[英]C# List of Panels

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. 就像iPhone上的iTunes如何显示可用的应用程序列表一样。

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. 是否有人想与我分享与样品的想法或链接。

Thanks in advance, Rob 在此先感谢,Rob

In sum, the following creates a series of panels within a container that scroll in and out of view using a vertical scroll bar. 总之,以下内容在容器内创建了一系列面板,这些面板使用垂直滚动条滚动进出视图。

You did not list ASP.NET in your tags, so I assume this is Windows form-based, not web based. 您没有在标签中列出ASP.NET,因此我假设这是基于Windows表单的,而不是基于Web的。 I'll get you started: 我会让你开始:

  1. Create a panel called GrandChildPanel . 创建一个名为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 (ie, iTunes song). 每个项目(例如iTunes歌曲)的此面板都将重复。
  2. Put that panel inside another, equal-width, equal-height panel called ChildPanel . 将该面板放在另一个名为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. 创建另一个名为ParentPanel面板,并将其宽度设置为其他面板的大小,再加上足够的空间用于垂直滚动条。 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 . ChildPanel放在ParentPanel右上角,并将垂直滚动条添加到ParentPanel的最右边缘。 Set the scroll bar's height to takeup the entire height of ParentPanel . 设置滚动条的高度以ParentPanel的整个高度。
  5. You probably want to add a border to ParentPanel to show its boundaries. 您可能想要向ParentPanel添加边框以显示其边界。
  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. 您可能还想在GrandChildPanel的底部添加一条1或2像素的线,以显示面板的结束位置。

That's the setup. 这就是设置。 Here are the requirements for your code: Each time you 'add an item to the list' (eg, every song in your iTunes list), you do the following: 这是您的代码要求:每次“将项目添加到列表”(例如,iTunes列表中的每首歌曲)时,都需要执行以下操作:

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

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 . 现在,要使此滚动成为可滚动状态,您只需对垂直滚动条的滚动或更改事件执行以下操作:将ChildPanelTop设置为等于垂直滚动条的值(“位置”)乘以-1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM