|
-
Jan 16th, 2009, 12:14 AM
#1
Thread Starter
Junior Member
[2008] Disabled multi-line text box that's scrollable... possbile?
Is it possible to make a multi-line text box still scrollable while it's disabled?
The closest I can achieve this is to set the text box's ReadOnly property to false, which will gray out the text box, and still scrollable, but the text in the box remains black instead of being gray. Changing the forecolor of the text box does not have any effect. The color of the text changes back to black when I set ReadOnly to true.
I want to be able to mimic the disabled text box visually. Thanks for the help!
-
Jan 16th, 2009, 12:36 AM
#2
Re: [2008] Disabled multi-line text box that's scrollable... possbile?
It's not possible. Disabled means disabled. Perhaps if you were to inherit the class and mess around with the internals but I wouldn't like to hazard a guess as to what exactly you'd need to do.
-
Jan 16th, 2009, 04:17 AM
#3
Member
Re: [2008] Disabled multi-line text box that's scrollable... possbile?
you could just make a small function that works on a timer ticking (set the tick timer to, say, 10) and then use this
Code:
textbox1.clear()
textbox1.text = "put your original text here)
This will reset the text whenever the timer ticks
Hope it helps
Ryy
currently studying on a VB course as well as part time self teaching C#
-
Jan 16th, 2009, 05:57 AM
#4
Re: [2008] Disabled multi-line text box that's scrollable... possbile?
 Originally Posted by ryytikki
you could just make a small function that works on a timer ticking (set the tick timer to, say, 10) and then use this
Code:
textbox1.clear()
textbox1.text = "put your original text here)
This will reset the text whenever the timer ticks
Hope it helps
Ryy
Thats a really bad way of doing it in my opinion. For one thing having a timer running every 10 ms has got to have some kind of impact on performance and for another thing it is just plain bad design. You would probably also find that the text appears to be constantly flickering if its getting cleared and reset every 10 miliseconds.
The way I would do it would be to just set the forecolor and backcolor manually and leave the ReadOnly property as False, then just use the KeyDown event like this to stop users being able to type into it:
vb.net Code:
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
e.SuppressKeyPress = True
End Sub
Last edited by chris128; Jan 16th, 2009 at 06:09 AM.
-
Jan 16th, 2009, 07:18 AM
#5
Re: [2008] Disabled multi-line text box that's scrollable... possbile?
vb.net Code:
Public Class Form1 Inherits System.Windows.Forms.Form Private Sub Form1_Load( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs _ ) Handles MyBase.Load CustomTextBox1.ReadOnly = True CustomTextBox1.BackColor = Color.White CustomTextBox1.ForeColor = Color.Gray End Sub End Class Public Class CustomTextBox Inherits TextBox Protected Overrides Sub OnPaint( _ ByVal e As System.Windows.Forms.PaintEventArgs _ ) Dim brush As SolidBrush = New SolidBrush(ForeColor) e.Graphics.DrawString(Text, Font, brush, 0.0F, 0.0F) End Sub Public Sub New() MyBase.New() Me.SetStyle(ControlStyles.UserPaint, True) End Sub End Class
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
|