|
-
Feb 23rd, 2008, 09:43 AM
#1
Textbox Problem
I have a string(as StringBuilder) of 35,660 characters that I put into a textbox. The problem is that it is slow. AT first I thought my problem was the .tostring of the stringbuilder but that was not the case. In the end I created a rich textbox and executed the following in the debugger
tstRTB.Text = lstANSa(pANS.Value).ToString 'rich textbox
txtFOC.Text = lstANSa(pANS.Value).ToString 'textbox
The rich textbox example executes as soon as you press F8. The textbox version takes seconds.
What am I missing. BTW - I reversed the order of the statements but the results were the same.
-
Feb 23rd, 2008, 09:50 AM
#2
Re: Textbox Problem
What is pANS? What is lstANSa? Remember that we know nothing about your project other than what you tell us. With such cryptic variable names you can't assume that what you're doing is obvious.
-
Feb 23rd, 2008, 10:13 AM
#3
Re: Textbox Problem
lstansa is an array of stringbuilders. pans.value is a numeric up down.
dim s as string
s=lstANSa(pANS.Value).ToString
the above two lines execute as soon as you press F8.
if i then try to assign s to the textbox it takes seconds also.
-
Feb 23rd, 2008, 10:15 AM
#4
Re: Textbox Problem
Are you doing anything funky on the TextChanged event?
-
Feb 23rd, 2008, 10:16 AM
#5
Re: Textbox Problem
What's the textbox.MaxLength property is set to?
-
Feb 23rd, 2008, 10:46 AM
#6
Re: Textbox Problem
There is not a changed event in my code. maxlength, as i discovered, only applies to the ui. but it was set to 0.
-
Feb 23rd, 2008, 10:50 AM
#7
Re: Textbox Problem
something else i noticed about textbox. if i used the arrow keys they were becoming part of the text, at least right arrow was for sure. doesn't seem to happen in rich textbox.
-
Feb 23rd, 2008, 11:45 AM
#8
Member
Re: Textbox Problem
I used this code to test your original question. I noticed that if you set the textbox multiline property to false the textbox fills with the text as fast as the richtextbox. I also observed the the lag when the textbox was set to multiline. Not much you can do about that I guess but is there a reason why you wouldn't just use the richtextbox?
Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim s As New String("A"c, 36000)
Me.RichTextBox1.Text = s
Me.TextBox1.Text = s
End Sub
-
Feb 23rd, 2008, 11:57 AM
#9
Re: Textbox Problem
jw, thanks for the confirmation. i thought i was going crazy, though i already may be there. in the rich box multiline was true also, but does not seem to be affected.
i have switched to rich textbox and the problem went away. of course i have already found an aspect of rich textbox i don't like. when i paste into it it brings formatting with 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|