2011-06-28 98 views
1

我在WPF中有一個應用程序,我希望在我的文本框中只能看到字符串的末尾。字符串開頭的文本修整

enter image description here

XAML:

<Grid Height="109" Width="126"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="166*" /> 
     <RowDefinition Height="145*" /> 
    </Grid.RowDefinitions> 
    <TextBlock Text="10000004" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Width="40" Background="LightBlue"/> 
    <TextBlock Text="10000005" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Width="40" Grid.Row="1" Background="LightGreen"/> 
</Grid> 

回答

0
int Len = 4; //put this equcal to how many digits you need from last... 
//path is the actual string 
string endText = path.Substring(path.Length - Len, path.Length) 
+0

謝謝,但缺少的位數是動態的,它取決於控制寬度 – Erez

+0

所以是否有任何條件可以指定控制寬度將包含這麼多字符 –

相關問題