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. Image for the cookie policy date

Autoshow scrollbars in multiline textboxext

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 3.0.1.0. Thanks in advance, Christian

2 Replies

AR Anupama Roy Syncfusion Team 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.


AR Anupama Roy Syncfusion Team 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( "".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.

Loader.
Live Chat Icon For mobile
Up arrow icon