Ask a questionAsk a question
 

Answerdoes GetRectFromCharacterIndex work?????

  • Tuesday, November 03, 2009 9:01 PMmarck68 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    this does not seems to work
     TextBox2.Text = TextBox1.GetRectFromCharacterIndex(TextBox1.Text.Length).Width & "/" & TextBox1.GetRectFromCharacterIndex(TextBox1.Text.Length).Height & "=" & TextBox1.Text.Length

    it does not matters how much text i write in thext box but the .wdith and heigh of the rect is fixed while the TextBox1.Text.Length gives the right results


    why is that


    <Window x:Class="Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="471" Width="858">

     <Grid>
      <Button Height="23" HorizontalAlignment="Right" Margin="0,124,186,0" Name="Button1" VerticalAlignment="Top" Width="75">Button</Button>
      <TextBox Margin="35,37,357,91" Name="TextBox1" AcceptsReturn="True" AcceptsTab="True"
      TextChanged="TextBox1_TextChanged" ></TextBox>
      <TextBox Height="65" HorizontalAlignment="Right" Margin="0,30,40,0" Name="TextBox2" VerticalAlignment="Top" Width="201" />
     </Grid>



     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
     
            TextBox2.Text = TextBox1.GetRectFromCharacterIndex(TextBox1.Text.Length).Width & "/" & TextBox1.GetRectFromCharacterIndex(TextBox1.Text.Length).Height & "=" & TextBox1.Text.Length
            Beep()

        End Sub

Answers

All Replies