显示控件的集合在Windows窗体 [英] Displaying a collection of controls in Windows Forms

查看:376
本文介绍了显示控件的集合在Windows窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要显示类似以下内容: -

I want to display something like the following :-

每行大约一个过程(信息,如PID,家长等)。用户可以检查复选框,然后单击启动按钮,获取有关该过程的一些动态信息。

Each row is about a process (information like PID, Parent etc.). User can check the checkbox and click Launch button to get some dynamic details about that process.

问题是,的CheckedListBox 控件不允许多个列和其他控件像的ListView (允许多列)不允许像 CheckBox控件被嵌入在列。

The problem is that CheckedListBox control doesn't allow more than one columns and other controls like ListView (which allow multiple columns) don't allow controls like checkbox to be embedded in a columns.

我想知道是否有一个控制,这将让我有自定义控件一个列表,其中每个自定义控件包含复选框某些文本一些动态文本

I want to know if there is a control which will allow me to have a list of custom controls where each custom control contains a checkbox, Some Text and Some Dynamic Text.

这怎么能在Windows窗体中实现? 。在此先感谢

How can this be achieved in Windows Forms? Thanks in advance.

推荐答案

有您可以使用许多选项:

There are many options you can use:


  • 您可以使用DataGridView中显示多列

  • 使用面板 FlowLayoutPanel的承载用户控件这是

  • 主机
  • 使用TableLayoutPanel中的
    包含您的组件。

  • You can use DataGridView to show multiple columns
  • use Panel or FlowLayoutPanel that hosts a UserControl that hosts that
  • use TableLayoutPanel contains your components.

例1:结果
。如果你想显示复选框文本框组合框按钮图片链接您可以简单地使用 DataGridView的

Example 1:
If you want to show CheckBox, TextBox, ComboBox, Button, Image, Link you can simply use DataGridView.

电网与 RowHeaderVisible Col​​umnHeaderVisible 设置为

示例2:

如果你需要自定义控制,以承载更多的复杂的控制或有对组件的更多控制,您可以创建一个用户控件托管组件,然后:

If you need custom control to host more complicated controls or having more control on components, you can create a UserControl hosting your components, then:


  • 如果您只想自上而下流动,使用面板和用户控件与 码头设置为控件的属性Top添加到它

  • 如果您可能要流以外自上而下的使用 FlowLayoutPanel的补充的情况下,您的控制它。

  • If you only want top-down flow, Use a Panel and add your user control to it with Dock property of control set to Top.
  • If you may want flows other than top-down Use a FlowLayoutPanel to add instances of your control to it.

创建一个用户控件

添加它的实例到你的面板 FlowLayoutPanel的

Add instances of it to your Panel or FlowLayoutPanel

这篇关于显示控件的集合在Windows窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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