Results 1 to 11 of 11

Thread: [RESOLVED] TextBox.GetLastVisibleLineIndex-Method not available

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Location
    Germany, near Munich
    Posts
    172

    Resolved [RESOLVED] TextBox.GetLastVisibleLineIndex-Method not available

    Hi all,

    I found a TextBox.GetLastVisibleLineIndex-method in the online documentation. But it is not available in my code. I´m using Visual Basic 2008 Express Edition. Is that the reason?

    Greetings,

    TheTree
    ********* Look at http://www.bahai.org - and enjoy it! *********

  2. #2
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    Re: TextBox.GetLastVisibleLineIndex-Method not available

    I don't know where you saw that but here's the methods list of the TextBox on msdn and GetLastVisibleLineIndex is not one of them.
    Alex
    .NET developer
    "No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)

    Things to consider before posting.
    Don't forget to rate the posts if they helped and mark thread as resolved when they are.


    .Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
    My fresh new blog : writingthecode, even if I don't post much.

    System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: TextBox.GetLastVisibleLineIndex-Method not available

    it's listed in object browser

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Location
    Germany, near Munich
    Posts
    172

    Re: TextBox.GetLastVisibleLineIndex-Method not available

    and it´s listed here: ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.de/fxref_system.windows.controls/html/e90bae0d-ddb7-ee24-67ad-f2228bb17cd7.htm

    Greetings,

    TheTree
    ********* Look at http://www.bahai.org - and enjoy it! *********

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: TextBox.GetLastVisibleLineIndex-Method not available

    i found it. it's WPF

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Location
    Germany, near Munich
    Posts
    172

    Re: TextBox.GetLastVisibleLineIndex-Method not available

    Hi .paul,

    thanks for your reply.

    What do I have to do, to use WPF-methods. Can I install something to Visual Basic 2008 Express Edition to use it?

    Greetings,

    TheTree
    ********* Look at http://www.bahai.org - and enjoy it! *********

  7. #7
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    Re: TextBox.GetLastVisibleLineIndex-Method not available

    Yeah I just noticed that it IS in textbox members list even if its not in its methods list on msdn.

    As we can see here its assembly is PresentationFramework.

    that explains it, thanks .paul.
    Alex
    .NET developer
    "No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)

    Things to consider before posting.
    Don't forget to rate the posts if they helped and mark thread as resolved when they are.


    .Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
    My fresh new blog : writingthecode, even if I don't post much.

    System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: TextBox.GetLastVisibleLineIndex-Method not available

    you can do it with the sendmessage API:

    vb Code:
    1. Private Declare Function SendMessage Lib "user32" _
    2.             Alias "SendMessageA" (ByVal hwnd As Integer, _
    3.             ByVal wMsg As Integer, ByVal wParam As Integer, _
    4.             ByVal lParam As Integer) As Integer
    5.  
    6. Private Const EM_GETFIRSTVISIBLELINE As Integer = &HCE

    vb Code:
    1. Dim height As Integer = CInt(TextBox3.CreateGraphics().MeasureString(TextBox3.Lines(0), TextBox3.Font, TextBox3.Width).Height)
    2. MsgBox(((TextBox3.ClientSize.Height \ height) + SendMessage(TextBox3.Handle.ToInt32, EM_GETFIRSTVISIBLELINE, 0, 0)) - 1)

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Location
    Germany, near Munich
    Posts
    172

    Re: TextBox.GetLastVisibleLineIndex-Method not available

    Hi .paul.,

    Thank you very much. Now its running!

    I´m so glad!



    Thanks to Alex, too.

    Greetings,

    TheTree
    ********* Look at http://www.bahai.org - and enjoy it! *********

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: [RESOLVED] TextBox.GetLastVisibleLineIndex-Method not available

    here's an extensions module with 2 functions that extend the textbox class:

    vb Code:
    1. Module extensions
    2.  
    3.     Private Declare Function SendMessage Lib "user32" _
    4.             Alias "SendMessageA" (ByVal hwnd As Integer, _
    5.             ByVal wMsg As Integer, ByVal wParam As Integer, _
    6.             ByVal lParam As Integer) As Integer
    7.  
    8.     Private Const EM_GETFIRSTVISIBLELINE As Integer = &HCE
    9.  
    10.     <System.Runtime.CompilerServices.Extension()> _
    11.     Public Function GetFirstVisibleLineIndex(ByVal instance As TextBox) As Integer
    12.         Return SendMessage(instance.Handle.ToInt32, EM_GETFIRSTVISIBLELINE, 0, 0)
    13.     End Function
    14.  
    15.     <System.Runtime.CompilerServices.Extension()> _
    16.     Public Function GetLastVisibleLineIndex(ByVal instance As TextBox) As Integer
    17.         Dim height As Integer = CInt(instance.CreateGraphics().MeasureString("0123456789", instance.Font, instance.Width).Height)
    18.         Dim bottomLineIndex As Integer = ((instance.ClientSize.Height \ height) + SendMessage(instance.Handle.ToInt32, EM_GETFIRSTVISIBLELINE, 0, 0)) - 1
    19.         Return If(bottomLineIndex <= instance.Lines.GetUpperBound(0), bottomLineIndex, instance.Lines.GetUpperBound(0))
    20.     End Function
    21.  
    22. End Module

    to use the functions, add the module to your project, then:

    vb Code:
    1. MsgBox(TextBox1.GetFirstVisibleLineIndex)
    2. MsgBox(TextBox1.GetLastVisibleLineIndex)
    Last edited by .paul.; Mar 25th, 2010 at 01:25 PM.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Location
    Germany, near Munich
    Posts
    172

    Re: [RESOLVED] TextBox.GetLastVisibleLineIndex-Method not available

    Wow. That´s perfect!

    Thank you very much.

    TheTree
    ********* Look at http://www.bahai.org - and enjoy it! *********

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width