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;
}
}
It's result will be like this
What i need is, If i click button 2.It's content(2) should be superscript of 5 (textbox value). if i click button 3,It's content(3) should be subscript of 5 textbox value.What i have to do to get the result what i need.
You need to implement a RichTextBox control.
Then take a look at this example .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.