Results 1 to 3 of 3

Thread: Auto Scroll TextBox

  1. #1

    Thread Starter
    Lively Member fifo's Avatar
    Join Date
    Dec 2005
    Location
    HaiPhong, Vietnam
    Posts
    77

    Auto Scroll TextBox

    Hi, Experts
    I want to create a auto scroll Textbox in C#. But I dont know how to make text box scroll by coding.

    Please, help me.
    !Have fun!

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Auto Scroll TextBox

    you could do it with API:
    Code:
    //add this
    using System.Runtime.InteropServices;
    
    //then the code is:
    public partial class Form1 : Form
    {
        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
        static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
    
        const int EM_LINESCROLL = 0xB6;
    
        public Form1()
        {
            InitializeComponent();
            for (int n = 0; n < 20; n++)
            {
                textBox1.Text += (n.ToString() + Environment.NewLine);
            }
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            // scroll up
            SendMessage(textBox1.Handle, EM_LINESCROLL, IntPtr.Zero, (IntPtr)(-1));
        }
    
        private void button2_Click(object sender, EventArgs e)
        {
            // scroll down
            SendMessage(textBox1.Handle, EM_LINESCROLL, IntPtr.Zero, (IntPtr)1);
        }
    }

  3. #3
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    Re: Auto Scroll TextBox

    I believe.. because John has said it 3,793 times.. that.. if you use append text it autoscrolls to where the text is.. if that's what you want

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width