|
-
Mar 24th, 2010, 12:43 PM
#1
Thread Starter
Addicted Member
[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
-
Mar 24th, 2010, 01:05 PM
#2
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 
-
Mar 24th, 2010, 01:09 PM
#3
Re: TextBox.GetLastVisibleLineIndex-Method not available
it's listed in object browser
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 24th, 2010, 01:12 PM
#4
Thread Starter
Addicted Member
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
-
Mar 24th, 2010, 01:45 PM
#5
Re: TextBox.GetLastVisibleLineIndex-Method not available
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 24th, 2010, 01:52 PM
#6
Thread Starter
Addicted Member
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
-
Mar 24th, 2010, 01:54 PM
#7
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 
-
Mar 24th, 2010, 02:10 PM
#8
Re: TextBox.GetLastVisibleLineIndex-Method not available
you can do it with the sendmessage API:
vb Code:
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Integer, _
ByVal wMsg As Integer, ByVal wParam As Integer, _
ByVal lParam As Integer) As Integer
Private Const EM_GETFIRSTVISIBLELINE As Integer = &HCE
vb Code:
Dim height As Integer = CInt(TextBox3.CreateGraphics().MeasureString(TextBox3.Lines(0), TextBox3.Font, TextBox3.Width).Height)
MsgBox(((TextBox3.ClientSize.Height \ height) + SendMessage(TextBox3.Handle.ToInt32, EM_GETFIRSTVISIBLELINE, 0, 0)) - 1)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 24th, 2010, 02:28 PM
#9
Thread Starter
Addicted Member
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
-
Mar 24th, 2010, 02:29 PM
#10
Re: [RESOLVED] TextBox.GetLastVisibleLineIndex-Method not available
here's an extensions module with 2 functions that extend the textbox class:
vb Code:
Module extensions
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Integer, _
ByVal wMsg As Integer, ByVal wParam As Integer, _
ByVal lParam As Integer) As Integer
Private Const EM_GETFIRSTVISIBLELINE As Integer = &HCE
<System.Runtime.CompilerServices.Extension()> _
Public Function GetFirstVisibleLineIndex(ByVal instance As TextBox) As Integer
Return SendMessage(instance.Handle.ToInt32, EM_GETFIRSTVISIBLELINE, 0, 0)
End Function
<System.Runtime.CompilerServices.Extension()> _
Public Function GetLastVisibleLineIndex(ByVal instance As TextBox) As Integer
Dim height As Integer = CInt(instance.CreateGraphics().MeasureString("0123456789", instance.Font, instance.Width).Height)
Dim bottomLineIndex As Integer = ((instance.ClientSize.Height \ height) + SendMessage(instance.Handle.ToInt32, EM_GETFIRSTVISIBLELINE, 0, 0)) - 1
Return If(bottomLineIndex <= instance.Lines.GetUpperBound(0), bottomLineIndex, instance.Lines.GetUpperBound(0))
End Function
End Module
to use the functions, add the module to your project, then:
vb Code:
MsgBox(TextBox1.GetFirstVisibleLineIndex)
MsgBox(TextBox1.GetLastVisibleLineIndex)
Last edited by .paul.; Mar 25th, 2010 at 01:25 PM.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 24th, 2010, 02:32 PM
#11
Thread Starter
Addicted Member
Re: [RESOLVED] TextBox.GetLastVisibleLineIndex-Method not available
Wow. That´s perfect!
Thank you very much.
TheTree
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|