Private Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim i As Integer
Dim txtBox As TextBox
For i = 1 To Cint(DropDownList1.SelectedItem.Value)
txtBox = New TextBox
With txtBox
.Text = "My Customer"
.Font.Size = "30"
End With
Me.pnlMain1.Controls.Add(lblText)
Next
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropDownList1.SelectedIndexChanged
Dim i As Integer
Dim txtBox As TextBox
For i = 1 To CInt(DropDownList1.SelectedItem.Value)
txtBox = New TextBox
With txtBox
.Text = "My Customer"
.Font.Size = "30"
End With
Me.pnlMain1.Controls.Add(txtBox)
Next
End Sub
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Q1_DDL_TX
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
loadDD();
}
private void loadDD()
{
var S = 5;
for (int i = 1; i <= S; i++)
{
comboBox1.Items.Add(i);
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//MessageBox.Show(comboBox1.SelectedItem.ToString());
var s = Convert.ToInt32(comboBox1.SelectedItem.ToString());
for (int i = 0; i < s; i++)
{
TextBox textbox = new TextBox();
int count = panel1.Controls.OfType<TextBox>().ToList().Count; ;
textbox.Location = new System.Drawing.Point(60, 25 * count);
textbox.Size = new System.Drawing.Size(80, 20);
textbox.Name = "textbox_" + (count + 1);
textbox.TextChanged += new System.EventHandler(this.TextBox_Changed);
panel1.Controls.Add(textbox);
}
}
private void TextBox_Changed(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
}