We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Autoshow scrollbars in multiline textboxext

Thread ID:





44026 May 11,2006 08:09 AM UTC May 13,2006 12:52 PM UTC WinForms 2
Tags: Tools
Christian Rattat
Asked On May 11, 2006 08:09 AM UTC

Hi, I want to display the scrolbars of a textbox only when required, i.e. the entire text exceeds the size of the textbox. How can I reach that? We use Sf Suite Thanks in advance, Christian

Anupama Roy [Syncfusion]
Replied On May 12, 2006 12:49 PM UTC

Hi Christian, Sorry for the delay in response. Our TextBoxExt is derived from .Net TextBox and behaviour of scrollBar is exactly the same like in .Net TextBox. However,as a workaround,I believe you can measure each string in the Character array of the TextBoxExt to get each strings length in pixels and compare it with the bounds of the TextBoxExt.When the compared value exceeds the bounds of TextBoxExt,you can enable the ScrollBars.I am working on a sample for this which I have not completed yet. I will get back to you as soon as I complete it successfully. Thanks, Anu.

Anupama Roy [Syncfusion]
Replied On May 13, 2006 12:52 PM UTC

Hi Christian, I am uploading the sample that I have created.I could get this done with a simplified logic than the earlier one.And below is the code that I have used. private Syncfusion.Windows.Forms.Tools.TextBoxExt textBoxExt1; private int len=0; private void textBoxExt1_TextChanged(object sender, System.EventArgs e) { string[] texta = this.textBoxExt1.Text.Split( "\n".ToCharArray() ); int index = texta.Length; for ( int i = 0; i <= index-1; i++ ) { len=len + texta[ i ].Length; Console.WriteLine (len ); if(len >= this.textBoxExt1.Bounds.Width ) { this.textBoxExt1.ScrollBars = ScrollBars.Vertical ; } else { this.textBoxExt1.ScrollBars =ScrollBars.None ; } } } So far this worked well with my TextBoxExt.However please let me know if you have any difficulties. sample Regards, Anu.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon