您好
參考以下代碼
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SetText(10, 10, "測試");
}
/// <summary>
/// 找出符合座標的 TextBox 並且修改內容
/// </summary>
/// <param name="x">X座標</param>
/// <param name="y">Y座標</param>
/// <param name="strText">字串內容</param>
private void SetText(int x, int y, string strText)
{
foreach (var c in this.Controls)
{
if (c is TextBox)
{
TextBox tb = (TextBox)c;
if (tb.Location.X == x && tb.Location.Y == y)
{
tb.Text = strText;
}
}
}
}
}
}
歡迎參觀我的Blog.NET菜鳥自救會