TextRange(TextPointer, TextPointer) Oluşturucu
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Yeni aralığın başlangıç ve bitiş konumları olarak belirtilen iki TextRange konumu alarak TextPointer sınıfının yeni bir örneğini başlatır.
public:
TextRange(System::Windows::Documents::TextPointer ^ position1, System::Windows::Documents::TextPointer ^ position2);
public TextRange(System.Windows.Documents.TextPointer position1, System.Windows.Documents.TextPointer position2);
new System.Windows.Documents.TextRange : System.Windows.Documents.TextPointer * System.Windows.Documents.TextPointer -> System.Windows.Documents.TextRange
Public Sub New (position1 As TextPointer, position2 As TextPointer)
Parametreler
- position1
- TextPointer
Yeni TextRangeöğesini oluşturmak için kullanılan seçimin bir ucunu işaretleyen sabit bir tutturucu konumu.
- position2
- TextPointer
Yeni TextRangeöğesini oluşturmak için kullanılan seçimin diğer ucunu işaretleyen taşınabilir bir konum.
Özel durumlar
ve position1 aynı belge içinde konumlandırılmadığında position2 gerçekleşir.
veya position1 olduğunda position2nullgerçekleşir.
Örnekler
Aşağıdaki örnekte oluşturucunun kullanımı gösterilmektedir TextRange .
// This method returns a plain text representation of a specified FlowDocument.
string GetTextFromFlowDocument(FlowDocument flowDoc)
{
// Create a new TextRanage that takes the entire FlowDocument as the current selection.
TextRange flowDocSelection = new TextRange(flowDoc.ContentStart, flowDoc.ContentEnd);
// Use the Text property to extract a string that contains the unformatted text contents
// of the FlowDocument.
return flowDocSelection.Text;
}
' This method returns a plain text representation of a specified FlowDocument.
Private Function GetTextFromFlowDocument(ByVal flowDoc As FlowDocument) As String
' Create a new TextRanage that takes the entire FlowDocument as the current selection.
Dim flowDocSelection As New TextRange(flowDoc.ContentStart, flowDoc.ContentEnd)
' Use the Text property to extract a string that contains the unformatted text contents
' of the FlowDocument.
Return flowDocSelection.Text
End Function
Açıklamalar
, TextRangeTextPointers tarafından belirtilen iki konum arasındaki seçimden oluşturulur. Bu konumlardan biri (ile gösterilir position1) seçime göre sabitken, diğer konum (ile position2gösterilir) taşınabilir. Bu, fare veya klavye kullanan bir kullanıcı tarafından yapılan seçimin davranışına benzer.
Yeninin gerçek uçları, yeni TextRangeTextRangeöğesini içeren belge için geçerli olan seçim buluşsal yöntemleriyle eşleşecek şekilde ayarlanabilir.