Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft ab, ob der Text im Steuerelement auf der Basislinie, hochgestellt oder tiefergestellt unterhalb der Basislinie angezeigt wird, oder legt diesen fest.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Property SelectionCharOffset As Integer
'Usage
Dim instance As RichTextBox
Dim value As Integer
value = instance.SelectionCharOffset
instance.SelectionCharOffset = value
public int SelectionCharOffset { get; set; }
public:
property int SelectionCharOffset {
int get ();
void set (int value);
}
/** @property */
public int get_SelectionCharOffset ()
/** @property */
public void set_SelectionCharOffset (int value)
public function get SelectionCharOffset () : int
public function set SelectionCharOffset (value : int)
Eigenschaftenwert
Eine Zahl, die den Zeichenversatz angibt.
Ausnahmen
| Ausnahmetyp | Bedingung |
|---|---|
Der angegebene Wert ist kleiner als -2000 oder größer als 2000. |
Hinweise
Der Wert dieser Eigenschaft muss zwischen -2000 und 2000 liegen.
Wenn diese Eigenschaft auf 0 (null) festgelegt ist, wird der Text auf der Basislinie angezeigt. Wenn sie auf eine positive Zahl festgelegt ist, gibt die Zahl die Anzahl der Pixel an, um die die Textauswahl über der Basislinie angezeigt werden soll. Wenn sie auf eine negative Zahl festgelegt ist, gibt diese Zahl die Anzahl der Pixel an, um die der markierte Text tiefergestellt werden soll. Sie können mit dieser Eigenschaft Text als hochgestellt oder tiefergestellt angeben.
Wenn kein Text markiert ist, wird der Offset auf die aktuelle Einfügemarke und auf nach der Einfügemarke eingegebenen Text angewendet. Der Zeichenversatz wird angewendet, bis die Eigenschaft auf einen anderen Wert geändert oder die Einfügemarke in einen anderen Abschnitt des Steuerelements verschoben wird.
Wenn Text im Steuerelement markiert ist, wird auf diesen und sämtlichen danach eingegebenen Text der Wert dieser Eigenschaft angewendet. Mit dieser Eigenschaft können Sie hochgestellten und tiefergestellten Text als mathematische Ausdrücke für entsprechende Anwendungen erstellen.
Beispiel
Das folgende Codebeispiel veranschaulicht die Verwendung der SelectionCharOffset-Eigenschaft zum Angeben von hochgestelltem und tiefgestelltem Text in der RichTextBox. Für dieses Beispiel ist es erforderlich, dass dem Formular ein RichTextBox-Steuerelement mit dem Namen richTextBox1 hinzugefügt wurde.
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
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:
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.set_SelectionFont(new Font("Lucinda Console", 12));
// Set the foreground color of the text.
richTextBox1.set_SelectionColor(Color.get_Purple());
// Set the baseline text.
richTextBox1.set_SelectedText("10");
// Set the CharOffset to display superscript text.
richTextBox1.set_SelectionCharOffset(10);
// Set the superscripted text.
richTextBox1.set_SelectedText("2");
// Reset the CharOffset to display text at the baseline.
richTextBox1.set_SelectionCharOffset(0);
richTextBox1.AppendText("\n\n");
// Change the forecolor of the next text selection.
richTextBox1.set_SelectionColor(Color.get_Blue());
// Set the baseline text.
richTextBox1.set_SelectedText("77");
// Set the CharOffset to display subscript text.
richTextBox1.set_SelectionCharOffset(-10);
// Set the subscripted text.
richTextBox1.set_SelectedText("3");
// Reset the CharOffset to display text at the baseline.
richTextBox1.set_SelectionCharOffset(0);
} //WriteOffsetTextToRichTextBox
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
RichTextBox-Klasse
RichTextBox-Member
System.Windows.Forms-Namespace