|
-
Jun 7th, 2010, 02:14 AM
#1
Thread Starter
Lively Member
-
Jun 7th, 2010, 02:30 AM
#2
Re: Multiline in TextBox
The multiline property is read-only at design time.
Perhaps you could use two textboxes. One that's default Multiline=True, and one that's not.
Software I use and highly recommend: Opera, Miranda IM, Peerblock, Winamp, Unlocker Assistant, JoyToKey, Virtual CloneDrive, Secunia PSI, ExplorerXP, GOM Player, Real Alternative, Quicktime Alternative,Sumatra PDF, and non-freeware: Photoshop and VB6( ).
My codebank: AllRGB, Rounded Rectangle(math), Binary Server, Buddy Paint, LoadPictureGDI+, System GUID/Volume Serial, HexToAsc, List all processes and their paths, quasiString matching
Strings(search, extraction, retrieval etc): Retrieve BBCode Link from HTML, RemoveBetween ()'s, strFindBetween(str1,str2), Insert text in HTML, HTML - GetSpanByID
-
Jun 7th, 2010, 02:38 AM
#3
Thread Starter
Lively Member
Re: Multiline in TextBox
tow text box is problem for me
can we do this property by API like ScrollBars
thank you
-
Jun 7th, 2010, 02:50 AM
#4
Re: Multiline in TextBox
Your usercontrol is based on Textbox control so it is like an "extended" control. There isn't any better solution than what FireXtol suggested since you are basing it on a standard textbox.
I guess you will also face a problem with .Wrap property?
The only solution is to have several textboxes with different styles and one local variable of type TextBox. When loading, decide from the flags what textbox you should use and set local variable to reference that textbox. Once done just operate the textbox through the local variable. It goes unsaid that the rest of them will be hidden....
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Jun 7th, 2010, 03:41 AM
#5
Re: Multiline in TextBox
More ways:
Default multiline = true. On Change, find newline characters and remove them for 'single line' mode.
Apparently you can also subclass the WM_CREATE message, and at this crucial moment you can use API to change multiline. But don't take my word for it.
Software I use and highly recommend: Opera, Miranda IM, Peerblock, Winamp, Unlocker Assistant, JoyToKey, Virtual CloneDrive, Secunia PSI, ExplorerXP, GOM Player, Real Alternative, Quicktime Alternative,Sumatra PDF, and non-freeware: Photoshop and VB6( ).
My codebank: AllRGB, Rounded Rectangle(math), Binary Server, Buddy Paint, LoadPictureGDI+, System GUID/Volume Serial, HexToAsc, List all processes and their paths, quasiString matching
Strings(search, extraction, retrieval etc): Retrieve BBCode Link from HTML, RemoveBetween ()'s, strFindBetween(str1,str2), Insert text in HTML, HTML - GetSpanByID
-
Jun 7th, 2010, 05:12 AM
#6
Thread Starter
Lively Member
Re: Multiline in TextBox
thank you very much FireXtol
give me Example or Code .. Please
For the second time I repeat my thanks to you
-
Jun 7th, 2010, 11:51 AM
#7
Re: Multiline in TextBox
Sure? I'll google that for you.
 Originally Posted by Rick Rothstein from http://www.codenewsgroups.net/group/microsoft.public.vb.general.discussion/topic10420.aspx
More than likely, this response will not be the one you use; but I'll post
it in case.<g>
The code below will allow you to set the maximum number of lines that a
TextBox can accept. If you want a non-multiline TextBox, simply set the
MaxLines variable to 1; if you want a multiline TextBox with 10 lines of
text maximum, set the MaxLines variable to 10. If you are showing
ScrollBars, they will "activate" if MaxLines is larger than the maximum
number of visible lines of text the TextBox can display.
So, you are probably asking, why might this not be what you want? Well, if
MaxLines is set to 1, then the maximum amount of text the user can type in
is limited to the width of the TextBox... no sideways scrolling of text for
the single line condition. Also, the ScrollBars that need to be displayed
for the multiline condition will remain visible when MaxLines is set to 1
(although you may be able to play with that using your posted API code).
And, of course, you need to fix the maximum number of lines that can be
typed in when in "multiline" mode. If you can live with these restrictions,
give the example code below a try.
Rick
Start a new project. Add a TextBox to the form and set its MultiLine
property to True and set the ScrollBars to 2-Vertical. Then paste this code
into the form's code window.
vb Code:
Dim MaxLines As Long
Private Declare Function SendMessageLong Lib _
"user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Const EM_LINEFROMCHAR = &HC9&
Private Sub Text1_Change()
Static LastText As String
Static LastCaretPos As Long
Static SecondTime As Boolean
Dim CurrentCaretPos As Long
Static NotFirstTime As Boolean
If NotFirstTime = False Then
NotFirstTime = True
Exit Sub
End If
With Text1
If Not SecondTime Then
CurrentCaretPos = .SelStart
.SelStart = Len(.Text)
If SendMessageLong(.hwnd, EM_LINEFROMCHAR, _
-1&, 0&) + 1 > MaxLines Then
Beep
SecondTime = True
.Text = LastText
.SelStart = LastCaretPos
Else
LastText = .Text
.SelStart = CurrentCaretPos
LastCaretPos = .SelStart
End If
End If
End With
SecondTime = False
End Sub
Private Sub Form_Load()
' Here, I am setting MaxLines to 100 lines just to give
' the code something to work with initially. You can set
' this initial value to whatever you want and, of course,
' reset it to any other value (for example, 1 to make it
' a single line entry TextBox
MaxLines = 100
End Sub
Software I use and highly recommend: Opera, Miranda IM, Peerblock, Winamp, Unlocker Assistant, JoyToKey, Virtual CloneDrive, Secunia PSI, ExplorerXP, GOM Player, Real Alternative, Quicktime Alternative,Sumatra PDF, and non-freeware: Photoshop and VB6( ).
My codebank: AllRGB, Rounded Rectangle(math), Binary Server, Buddy Paint, LoadPictureGDI+, System GUID/Volume Serial, HexToAsc, List all processes and their paths, quasiString matching
Strings(search, extraction, retrieval etc): Retrieve BBCode Link from HTML, RemoveBetween ()'s, strFindBetween(str1,str2), Insert text in HTML, HTML - GetSpanByID
-
Jun 7th, 2010, 02:10 PM
#8
Thread Starter
Lively Member
Re: Multiline in TextBox
in normal text can is set mlutiline = true or false by code in any way
Last edited by SNIPER.PS; Jun 7th, 2010 at 02:14 PM.
-
Jun 7th, 2010, 03:07 PM
#9
Re: Multiline in TextBox
 Originally Posted by SNIPER.PS
in normal text can is set mlutiline = true or false by code in any way
Research subclassing. It's the only way in VB(unless you create the control in another language... but either way you'll be dealing with the same kinds of API).
I've little experience with subclassing, and I honestly don't know how to do it.
Software I use and highly recommend: Opera, Miranda IM, Peerblock, Winamp, Unlocker Assistant, JoyToKey, Virtual CloneDrive, Secunia PSI, ExplorerXP, GOM Player, Real Alternative, Quicktime Alternative,Sumatra PDF, and non-freeware: Photoshop and VB6( ).
My codebank: AllRGB, Rounded Rectangle(math), Binary Server, Buddy Paint, LoadPictureGDI+, System GUID/Volume Serial, HexToAsc, List all processes and their paths, quasiString matching
Strings(search, extraction, retrieval etc): Retrieve BBCode Link from HTML, RemoveBetween ()'s, strFindBetween(str1,str2), Insert text in HTML, HTML - GetSpanByID
-
Jun 7th, 2010, 04:03 PM
#10
Re: Multiline in TextBox
See TextBoxEx Control (Free, with sourecode) at:
http://www.vbaccelerator.com/codelib...t/txtboxex.htm
It can set MultiLine at runtime. It does this by saving the Text and recreating the control on the fly.
Requires SsubTmr6.Dll:
http://www.vbaccelerator.com/home/VB...er/article.asp
or download just the binary at:
http://www.vbaccelerator.com/home/VB...Tmr_Binary.asp
Last edited by DrUnicode; Jun 7th, 2010 at 04:03 PM.
Reason: Typo
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
|