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 文本框值。我需要做什么才能得到我需要的结果。