RichTextBox.SelectionCharOffset Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene o imposta un valore che indica se il testo nel controllo viene visualizzato nella linea di base, come apice o come pedice sotto la linea di base.
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
Valore della proprietà
Numero che specifica l'offset di caratteri.
- Attributi
Eccezioni
Il valore specificato è minore di -2000 o maggiore di 2000.
Esempio
Nell'esempio di codice seguente viene illustrato come specificare testo apice e pedice all'interno della RichTextBox proprietà utilizzando la SelectionCharOffset proprietà . In questo esempio è necessario che al modulo sia stato aggiunto un RichTextBox controllo denominato richTextBox1.
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
Commenti
Il valore di questa proprietà deve essere compreso tra -2000 e 2000.
Se questa proprietà è impostata su zero, il testo viene visualizzato nella linea di base. Se è un numero positivo, il numero specifica il numero di pixel in base al quale generare la selezione del testo sopra la linea di base. Se è un numero negativo, questo numero specifica il numero di pixel in base al quale descriva la selezione del testo. È possibile utilizzare questa proprietà per specificare il testo come apice o pedice.
Se non è selezionato alcun testo, l'offset viene applicato al punto di inserimento corrente e a tutto il testo digitato dall'utente dopo il punto di inserimento. L'offset di caratteri viene applicato fino a quando la proprietà non viene modificata in un valore diverso o fino a quando il punto di inserimento non viene spostato in una sezione diversa all'interno del controllo.
Se il testo viene selezionato all'interno del controllo, il testo selezionato e qualsiasi testo immesso dopo la selezione del testo avrà il valore di questa proprietà applicato. È possibile utilizzare questa proprietà per creare testo apice e pedice per applicazioni come espressioni matematiche.