public partial class SupperSub : Window
{
Control _txtbox;
Control _bt;
public SupperSub()
{
this.InitializeComponent();
}
private void TextBox_GotFocus(object sender, System.Windows.RoutedEventArgs e)
{
_txtbox = (Control)sender;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
_bt = (Control)sender;
TextBox CastingTxt = _txtbox as TextBox;
Button CastingBtn = _bt as Button;
var Index = CastingTxt.CaretIndex;
CastingTxt.Text = CastingTxt.Text.Insert(Index,CastingBtn.Content.ToString());
CastingTxt.Focus();
CastingTxt.CaretIndex = Index +1;
}
}
结果会是这样
我需要的是,如果我单击按钮 2。它的内容(2)应该是5 的上标(文本框值)。如果我单击按钮 3,它的内容(3)应该是5 个文本框值的下标。我必须做什么才能得到我需要的结果。