本文介绍了如何使用C#生成Dynamicaly行和列,就像在Windows中的表一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码
This is my Code
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private List<textbox> inputTextBoxes;
public Form1()
{
InitializeComponent();
this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
this.AutoSize = true;
this.Padding = new Padding(0, 0, 20, 20);
this.StartPosition = FormStartPosition.CenterScreen;
}
private void btnadd_Click(object sender, EventArgs e)
{
int inputNumber = Int32.Parse(textBox1.Text);
inputTextBoxes = new List<textbox>();
inputTextBoxes = new List<textbox>();
for (int i = 1; i <= inputNumber; i++)
{
Label labelInput = new Label();
TextBox textBoxNewInput = new TextBox();
labelInput.Text = " " + i;
labelInput.Location = new Point(30, textBox1.Bottom + (i * 30));
labelInput.AutoSize = true;
textBoxNewInput.Location = new Point(labelInput.Width, labelInput.Top - 3);
inputTextBoxes.Add(textBoxNewInput);
this.Controls.Add(labelInput);
this.Controls.Add(textBoxNewInput);
}
}
}
但我想要三列标题,如S.No,Name ,目标和行基于在文本框中输入的值
But i want Three column Heading like S.No,Name,Destination and rows based on the value entered in the text box
推荐答案
这篇关于如何使用C#生成Dynamicaly行和列,就像在Windows中的表一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!