可否在TextBox或RichTextBox中实现类似于Word中字符上标和下标的功能?
如果不行,那么用其它什么控件可以实现对输入字符可以上下标的功能?

解决方案 »

  1.   

    直接嵌入一个word文档对象在窗体中应该可以
      

  2.   

    同意楼上的,嵌入word,嵌入word的方法在我资源里有
      

  3.   

    这种复杂显示,我都是用html来实现,用WebBrowser控件
      

  4.   

    参考RichTextBox.SelectionCharOffset属性
    private void WriteOffsetTextToRichTextBox()
    {
        // Clear all text from the RichTextBox.
        richTextBox1.Clear();
        // Set the font for the text.
        richTextBox1.SelectionFont = new Font("Lucinda Console", 12);
        // Set the foreground color of the text.
        richTextBox1.SelectionColor = Color.Purple;
        // Set the baseline text.
        richTextBox1.SelectedText = "10";
        // Set the CharOffset to display superscript text.
        richTextBox1.SelectionCharOffset = 10;
        // Set the superscripted text.    
        richTextBox1.SelectedText = "2";
        // Reset the CharOffset to display text at the baseline.
        richTextBox1.SelectionCharOffset = 0;
        richTextBox1.AppendText("\n\n");
        // Change the forecolor of the next text selection.
        richTextBox1.SelectionColor = Color.Blue;
        // Set the baseline text.
        richTextBox1.SelectedText = "77";
        // Set the CharOffset to display subscript text.
        richTextBox1.SelectionCharOffset = -10;
        // Set the subscripted text.  
        richTextBox1.SelectedText = "3";
        // Reset the CharOffset to display text at the baseline.
        richTextBox1.SelectionCharOffset = 0; 
    }
      

  5.   

    对头,我一般都是用richtextbox实现,把它拖小冒充普通的textbox.