สร้าง TextBox หลายอัน แล้วกำหนดค่าให้มัน (2009-09-08)
Public Class Form1
{
TextBox tbx = new TextBox[5];
int arr = {1, 2, 3, 4, 5};
//=======================================================================
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click <<< Event onclick ของ button1
{
for (int i = 0; i<arr.Length; i++)
tbx[i+1].Text = arr[i].ToString();
}
//=======================================================================
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load <<< Event PageLoad
{
SetArr();
}
//=======================================================================
private void SetArr()
{
tbx[1] = TextBox1;
tbx[2] = TextBox2;
tbx[3] = TextBox3;
tbx[4] = TextBox4;
}
}
//=======================================================================
มาจาก http://www.narisa.com/forums/index.php?showtopic=29161
|