我有多个XAML TextBox
es,其中每个修改TextBox
中的值时,使用C#
方法动态检查哪个TextBox
已调用该方法操纵数组中的相应值。动态设置文本框文本
<TextBox x:Name="_0_0" TextChanged="_x_y_TextChanged"/>
<TextBox x:Name="_0_1" TextChanged="_x_y_TextChanged"/>
<TextBox x:Name="_0_2" TextChanged="_x_y_TextChanged"/>
// And so on.....
其中的每一个在一个阵列中,当在TextBox
的值改变时,使用动态地检查哪个TextBox
已经调用方法的C#方法操纵的对应值。
private void _x_y_TextChanged(object sender, TextChangedEventArgs e)
{
TextBox current = (TextBox)sender;
string currentname = current.Name;
string rowstring = currentname.Substring(1, 1);
string columnstring = currentname.Substring(3, 1);
int row = Convert.ToInt32(rowstring);
int column = Convert.ToInt32(columnstring);
// I've then detected the name of the textbox which has called it...
所以这个信息可以用来动态存储从TextBox
信息在相应的数组索引 - 无论你想用它做或...
我的问题却是:
如何创建一个使用我的数组中的索引位置的方法来调用相关的TextBox
并更新其文本?
也许你可以通过一个简短的例子来充实你的答案,以显示你的意思。就目前而言,它有点缺乏有用的细节来帮助解决问题带来的问题。 –