RichTextBox.SelectionCharOffset Özellik

Tanım

Denetimdeki metnin taban çizgisinde mi, üst simge olarak mı yoksa taban çizgisinin altında bir alt simge olarak mı görüneceğini alır veya ayarlar.

public:
 property int SelectionCharOffset { int get(); void set(int value); };
[System.ComponentModel.Browsable(false)]
public int SelectionCharOffset { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionCharOffset : int with get, set
Public Property SelectionCharOffset As Integer

Özellik Değeri

Int32

Karakter uzaklığını belirten bir sayı.

Öznitelikler

Özel durumlar

Belirtilen değer -2000'den küçük veya 2000'den büyük.

Örnekler

Aşağıdaki kod örneği, özelliğini kullanarak SelectionCharOffset içinde RichTextBox üst simge ve alt simge metninin nasıl belirtileceğini gösterir. Bu örnek, forma adlı richTextBox1bir RichTextBox denetimin eklenmesini gerektirir.

private:
   void WriteOffsetTextToRichTextBox()
   {
      // Clear all text from the RichTextBox.
      richTextBox1->Clear();

      // Set the font for the text.
      richTextBox1->SelectionFont = gcnew System::Drawing::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;
   }
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; 
}
Private Sub 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.SelectedText = ControlChars.CrLf + ControlChars.CrLf
   ' Change the forecolor of the next text selection.
   RichTextBox1.SelectionColor = Color.Blue
   ' Set the baseline text.
   RichTextBox1.SelectedText = "777"
   ' 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
End Sub

Açıklamalar

Bu özelliğin değeri -2000 ile 2000 arasında olmalıdır.

Bu özellik sıfır olarak ayarlanırsa, metin taban çizgisinde görünür. Sayı pozitif bir sayıysa, metin seçiminin taban çizgisinin üzerine yükseltildiği piksel sayısını belirtir. Negatif bir sayıysa, bu sayı metin seçiminin alt simge olarak yazıldığı piksel sayısını belirtir. Metni üst simge veya alt simge olarak belirtmek için bu özelliği kullanabilirsiniz.

Metin seçilmezse, uzaklık geçerli ekleme noktasına ve kullanıcının ekleme noktasından sonra yaptığı tüm metne uygulanır. Özellik farklı bir değere değiştirilene veya ekleme noktası denetim içindeki farklı bir bölüme taşınana kadar karakter uzaklığı uygulanır.

Denetim içinde metin seçilirse, seçilen metin ve metin seçiminden sonra girilen tüm metinler bu özelliğin değerine uygulanır. Matematiksel ifadeler gibi uygulamalar için üst simge ve alt simge metni oluşturmak için bu özelliği kullanabilirsiniz.

Şunlara uygulanır