简体   繁体   English

如何创建此用户控件?

[英]How to create this user control?

I have to develop a small app for which I have to create a user control which is intended to be something like a Table View. 我必须开发一个小型应用程序,为此必须创建一个用户控件,该控件应类似于表视图。

On Form Load, the user should be asked about the number of rows of columns required on the form. 在“表单加载”中,应询问用户表单上所需的列数。

Once the user sets the number of cells, each cell should have a button and a Text Box inside it (grouped together). 一旦用户设置了单元格的数量,每个单元格内应有一个按钮和一个文本框(组合在一起)。 Please help me in creating the User Control. 请帮助我创建用户控件。 I am still a new learner. 我仍然是新手。 Thanks! 谢谢!

The DataGridView built-in class in the .NET Framework will display a grid with a text box that can be edited by a user. .NET Framework中的DataGridView内置类将显示一个带有文本框的网格,用户可以对其进行编辑。 To display an image you'll need to derive your our DataGridViewCell and write all the drawing and handling code to customize the cell. 要显示图像,您需要派生我们的DataGridViewCell并编写所有绘图和处理代码以自定义单元格。 You can see this example for how to do that: 您可以看到此示例以了解如何执行此操作:

http://www.codeproject.com/KB/grid/DGV_ImageButtonCell.aspx http://www.codeproject.com/KB/grid/DGV_ImageButtonCell.aspx

Another option would be to use a TableLayoutPanel . 另一种选择是使用TableLayoutPanel After the user specifies the number of rows and columns, you could create the TableLayoutPanel then iterate through each cell to add the appropriate control. 用户指定行数和列数后,可以创建TableLayoutPanel然后遍历每个单元格以添加适当的控件。

Each cell can only have 1 control so you'd have to make two columns to put a button and textbox next to each other. 每个单元只能有1个控件,因此您必须创建两列才能将按钮和文本框彼此相邻放置。

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

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