[英]How to place text between two html tags in C#
我正在用C#
制作一個簡單的HTML
編輯器。
我有一個boldText
按鈕,它在textArea
RichTextBox 中添加了一個<b> </b>
html 標簽。 我的目標是在textArea
輸入一個單詞,選擇它並按下該boldText
按鈕將單詞粘貼到粗體標簽之間。
例如: <b> Word </b>
。 就像在這里,在編輯器中,當您發布問題時。 希望我足夠清楚地解釋了我的問題。 這是我的按鈕代碼:
private void boldText_Click(object sender, EventArgs e)
{
textArea.SelectionLength = 0;
textArea.SelectedText = "<b> </b>";
}
如果我正確理解您的問題,也許您正在嘗試這樣做
private void boldText_Click(object sender, EventArgs e)
{
textArea.SelectedText = string.Format("<b>{0}</b>", textArea.SelectedText);
textArea.SelectionLength = 0;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.