• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

C#witn window application, how to make rich text box auto scroll???

and how to make the textbox auto-resize if the form resize?
0
karen1982
Asked:
karen1982
1 Solution
 
cookreCommented:
http://www.nullfx.com/index.php?name=PNphpBB2&file=viewtopic&t=7

I would think you'ld have to do the resize yourself, i.e., adjust top, left, width, and height dynamicaly in response to a window re-size to match your preferred proportions and percentage of its footprint within the window.
0
 
cookreCommented:
For example, let's say you want the box to be in the bottom left corner and have a height of 1/4 of the window's height and a width of 1/6 of the windows width, then

box.left=0
box.width=window.width/6
box.height=windowheight/4
box.top=windowheight - box.height
0
 
TheC2Commented:
For resize, you can set the anchors of the text box.
What you do is place the text box where you want on the form, and then set anchors in the relevant sides. Any side you set an anchor on will stay at it's current distance from that side on the form. For example, if you want it to resize along with the form, you'd have to set all the anchors.
It's a bit hard to explain, so I suggest you just try it, you can find it in the Properties pane when you select the text box in design view. After setting the anchors try to resize the form and see what happens.
I should say that anchors generally work, but I have encountered times when they can be quite a pain, but it's worth a try.
You can find more information here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclassanchortopic.asp

About the autoscroll, I didn't quite understand what you ment...
I can tell you that if you want the text box to scroll somewhere you can set the caret at this position and then call the ScrollToCaret method.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformstextboxbaseclassscrolltocarettopic.asp

Hope this helps...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
If you are adding lines to the end of a RTB and want it to autoscroll to that new line then give the RTB focus and use the AppendText() method.  Here is an example in VB.Net:

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Static i As Integer
        i = i + 1
        RichTextBox1.Focus()
        RichTextBox1.AppendText("Item" & i & vbCrLf)
    End Sub

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformstextboxbaseclassappendtexttopic.asp
0
 
karen1982Author Commented:
thanks for all of you guys reply,,
i tried to use the client size to do the resize, but didn't work out well,
and the scrolltocaret() didn't work well too,


what i am tring to do is, write an irc client, but when the messages come and i display that to the richtext box, but the text box doesn't auto scroll,, kind of pain to do that by hand
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
For the autoscroll with ScrollToCaret() or AppendText() to work, the RTB must have the focus FIRST.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now