#930 – LineCount Property Indicates Number of Lines in TextBox
October 17, 2013 1 Comment
LineCount is a read-only property of a TextBox that tells you the current number of lines in the TextBox.
<Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Label Content="Here's a TextBox:" /> <TextBox Name="txt1" Grid.Row="1" Margin="5" HorizontalAlignment="Stretch" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/> <Button Grid.Row="2" Padding="10,3" HorizontalAlignment="Center" Content="Get # Lines" Click="Button_Click"/> </Grid>
private void Button_Click(object sender, RoutedEventArgs e) { MessageBox.Show(txt1.LineCount.ToString()); }
Pingback: Dew Drop – October 17, 2013 (#1,647) | Morning Dew