#930 – LineCount Property Indicates Number of Lines in TextBox

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());
        }

930-001

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

One Response to #930 – LineCount Property Indicates Number of Lines in TextBox

  1. Pingback: Dew Drop – October 17, 2013 (#1,647) | Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: