locked
Textbox auto scroll problem? RRS feed

  • Question

  • Hi,

    i have create two textboxes, first have some text and another is blank just like typing tutor,

    i made selection on a character in first textbox one by one. and type a character in second text box. then compare for equality.

    thats works fine, but problem starts when i have enter long text in first text box it shows only first one line of text (as i set its height to 40 and font size to 27 pts) when i completed typing first line it selects next line's first character but it cannot be shown on screen.

    the following properties are customized by me of first text box:

    readonly = true,

    hideseletion=true

    wordwrap=true/false (any)

    I don't want to show any selection in first text box as i put formatting on selected character in it.

    but i want that first text box should show that character which i have selected in that text box by coding.

    Please solve my problem,

    Thanks in advance.


    SatnamGill

    Thursday, October 18, 2012 9:57 AM

Answers

  • i have solved this problem myself,

    thanks to internet, where I found the solution it is just..

    richtextbox1.scrollToCaret()

    Thanks


    SatnamGill

    • Marked as answer by GillSatnam Tuesday, December 4, 2012 9:47 AM
    Tuesday, December 4, 2012 9:47 AM

All replies

  • Hi GillSatnam,

    first of all welcome in MS-Forum.
    Second:

    Set your TextBox setting "Multiline" to True like:

    Me.TextBox1.Multiline = True
    Additional set a defined value for TextBox height e.g:

    Me.TextBox1.Height = 50       

    Set these values either with form load event or TextBox1_TextChanged (I guess the first tip).

    Good luck.


    Liebe Grüße Stefan | Cheers Stefan I'm using VB 2008 and VB 2010 Express Be a good forum member - mark posts that contain the answers to your questions or those that are helpful. c# in vb Translator: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Thursday, October 18, 2012 12:27 PM
  • Thanks for reply to my q.

    But it is not solving my problem.

    I already set these properties to textbox but it cannot show current character on screen.

    Please suggest me how to do this?


    SatnamGill

    Thursday, October 18, 2012 12:41 PM
  • Sorry, I missunderstud your issue.

    Maybe me second tip is better.

    I guess, you select a charcter or a group of charcters by mouse.

    If so, you should use the mouseup event. Here a little sample:

    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.TextBox1.Multiline = True
            Me.TextBox2.Multiline = True
            Me.TextBox1.WordWrap = True
            Me.TextBox2.WordWrap = True
        End Sub
    
        
        Private Sub TextBox1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseUp
            If e.Button = Windows.Forms.MouseButtons.Left Then
                Me.TextBox2.Text = Me.TextBox1.SelectedText
            End If
        End Sub
    End Class


    Liebe Grüße Stefan | Cheers Stefan I'm using VB 2008 and VB 2010 Express Be a good forum member - mark posts that contain the answers to your questions or those that are helpful. c# in vb Translator: http://www.developerfusion.com/tools/convert/csharp-to-vb/


    • Edited by Giftzwockel Thursday, October 18, 2012 12:55 PM
    Thursday, October 18, 2012 12:53 PM
  • I am sorry, but this is not my problem,

    i am developing a typing tutor for a regional language. and i create two richtextboxes. in first richtextbox i put some text and set its font to my regional language. and another text box is empty. i made selection in first textbox character by character and type a character in textbox2 then compare them. this works fine for me when i made richtextbox1.hideselection = false but when i set richtextbox1.hideselection=true then it doesn't show any selection in richtextbox1 which i want and show some formatting on same character in richtextbox1 as i want. but when i put some long text in richtextbox1 it wrapped to next line and goes down in richtextbox1 i don't want to show any scrollbars in richtextbox1 not selection in it. but want to show current selected character with its full line on distplay as it selected. i just type my text in richtextbox2.

    richtextbox2 have the focus and richtextbox1 have following properties:

    richtextbox1.multiline=true

    richtextox1.readonly=true

    richtextbox1.wordwrap = true

    richtextbox1.hideselection = true ( as i don't want to show any selection in it, but if i show selection it automaticaly scolled to current character. i want to do this without showing selection)

    OR

    is there any way to change color of selection highlight color (Default is blue in XP) for richtextbox1.

    If you understand me then please help me if not i can post my code or screen shots here.

    Thanks


    SatnamGill

    Friday, October 19, 2012 4:10 AM
  • Hi,

    checkTextBoxBase.HideSelection Property:http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.hideselection.aspx

     if the selected text does not appear highlighted when the text box control loses focus; false, if the selected text remains highlighted when the text box control loses focus. The default is true.


    No code, No fact.

    • Marked as answer by GillSatnam Tuesday, December 4, 2012 9:47 AM
    • Unmarked as answer by GillSatnam Tuesday, December 4, 2012 9:47 AM
    Monday, October 22, 2012 9:45 AM
  • i have solved this problem myself,

    thanks to internet, where I found the solution it is just..

    richtextbox1.scrollToCaret()

    Thanks


    SatnamGill

    • Marked as answer by GillSatnam Tuesday, December 4, 2012 9:47 AM
    Tuesday, December 4, 2012 9:47 AM