我正在爲我的A級計算項目製作一個彈丸運動模擬程序,我需要使用帶有下標的物理符號。我不知道如何在標籤或富文本框中使用它。 任何人都可以請給我幫助/代碼來實現這個?如何在Visual C#中顯示下標?
0
A
回答
2
+0
謝謝。我將如何顯示這樣的內容:http://i.imgur.com/B6xqx.png – user1920206
+0
這是一個上標。爲'SelectionCharOffset'使用一個正數。 –
+0
V位正常,垂直位爲下標。有沒有辦法選擇下標的零件? – user1920206
0
SelectioncharOffset是不是你最好的選擇。是更好地操作rtf並添加下標標籤。
//This allows you to reselect the text in the rtb after formatting
int SelectionStart = richTextBox1.SelectionStart;
int SelectionLength = richTextBox1.SelectionLength;
string selectedRtf = richTextBox1.SelectedRtf;
int Start;
int End;
string pre;
string Mid;
string post;
//remove superscript from selected text
Start = selectedRtf.IndexOf("\\super");
while (Start != -1)
{
pre = selectedRtf.Substring(0, Start);
post = selectedRtf.Substring(Start + 6, selectedRtf.Length - (Start + 6));
selectedRtf = pre.Trim() + post.Trim();
Start = selectedRtf.IndexOf("\\super");
}
//if selected text does not contain subscript
if (selectedRtf.IndexOf("\\sub") == -1 && selectedRtf.IndexOf("\\nosupersub") == -1)
{
Start = selectedRtf.IndexOf("}}") + 2;
End = selectedRtf.IndexOf("}", Start);
pre = selectedRtf.Substring(0, Start);
Mid = selectedRtf.Substring(Start, End - Start);
post = selectedRtf.Substring(End, selectedRtf.Length - End);
selectedRtf = pre + "\\sub" + Mid + "\\nosupersub" + post;
goto Clean;
}
//if selected text contains subscript
if (selectedRtf.IndexOf("\\sub") > 0)
{
Start = selectedRtf.IndexOf("\\sub");
while (Start != -1)
{
pre = selectedRtf.Substring(0, Start);
post = selectedRtf.Substring(Start + 4, selectedRtf.Length - (Start + 4));
selectedRtf = pre.Trim() + post.Trim();
Start = selectedRtf.IndexOf("\\sub");
}
goto Clean;
}
Clean:
richTextBox1.SelectedRtf = selectedRtf;
richTextBox1.Focus();
richTextBox1.SelectionStart = SelectionStart;
richTextBox1.SelectionLength = SelectionLength;
相關問題
- 1. Visual C#,如何在標籤中顯示「Unicode字符」?
- 2. 如何在Visual C#中的消息框中顯示整數?
- 3. 在visual studio 2010中顯示標尺
- 4. 如何讓qGLWidget在Visual Studio中顯示
- 5. 在標籤中顯示希臘字符(Visual Studio C#)
- 6. 如何在Visual Studio中顯示標記欄
- 7. 如何在Visual Studio中顯示垂直線以對齊標籤?
- 8. 如何在visual C++中表示空格?
- 9. 如何在Visual C++中使用openGL顯示消息框
- 10. 如何在visual C++中顯示系統信息?
- 11. 如何在RichEdit2 visual C++中顯示所有ASCII字符
- 12. 如何在Visual C++ 2008中顯示命令行構建選項?
- 13. 如何在C#Dropdownlist中使用html標籤顯示上標
- 14. 顯示ADDBTimeStamp用Visual C++ 6.0
- 15. 如何顯示標記下的文本
- 16. 如何顯示在下拉
- 17. 如何防止在Visual Studio下顯示控制檯窗口?
- 18. 如何在C#中的RichTextBox中顯示光標的位置
- 19. 如何在Visual C++下編譯WinCrypt.h?
- 20. 如何在iOS下顯示兩個以下的標籤文字?
- 21. 如何在模式下顯示標題下方的模式
- 22. C#如何顯示平臺目標
- 23. 如何顯示圖像的目標C
- 24. 如何在Django窗體中顯示下標字母?
- 25. 如何在iOS工具欄中顯示標準上/下控件
- 26. 如何在qlabel中顯示下標字符
- 27. 在C#中顯示下載選項
- 28. 在c中顯示下載進度#
- 29. 如何在UWP下顯示xaml中的數組C#
- 30. 如何顯示在下拉列表中
歡迎來到StackOverflow :)由於您是新手,並且您首次發帖,因此瞭解SO的工作原理是謹慎的。向我們表明您在理解您的問題方面所做的一些努力。 :)你有什麼嘗試?研究?你的大學/學院是否不告訴你如何進行研究?看,這不是粗魯的,但看到這個問題「*任何人都可以請給我幫助/代碼來實現這個?*」表示零努力,即懶惰...... :) – t0mm13b