This is a migrated thread and some comments may be shown as answers.

Expandable Multiline TextBox

1 Answer 354 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Garrett
Top achievements
Rank 1
Garrett asked on 06 Oct 2015, 06:32 PM

Is there a way to expand... grab a corner and pull to "show more" when the control is full?

Tried many searches for this... no luck.

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 08 Oct 2015, 03:00 PM
Hello Garett,

Thank you for writing back.

This type of functionality is not supported out of the box. You have, however, a couple of options which could help you in achieving a similar result. 

You could build a complex layout in a RadSplitContainer, dock your textbox is some of the panels and use the splitters to resize it. This article could help you in creating the layout: Building Advanced Layouts. Another option is to make the control automatically resize when it is full with text. Please check my code snippet below as well as the attached gif file: 
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        this.CreateGrid(this.radSplitContainer1, 2, 2, Orientation.Horizontal, true);
 
        this.radTextBoxControl1.Multiline = true;
        this.radTextBoxControl1.TextBoxElement.VScrollBar.ValueChanged += VScrollBar_ValueChanged;
    }
 
    private void VScrollBar_ValueChanged(object sender, EventArgs e)
    {
        this.radTextBoxControl1.TextBoxElement.VScrollBar.Value = 0;
        this.radTextBoxControl1.Size = new Size(this.radTextBoxControl1.Size.Width + 5, this.radTextBoxControl1.Size.Height + 5);
    }
 
    private void CreateGrid(RadSplitContainer container, int cols, int rows, Orientation orientation, bool centerFill)
    {
        container.Orientation = orientation;
 
        for (int i = 0; i < rows; i++)
        {
            RadSplitContainer newContainer = new RadSplitContainer();
            newContainer.Orientation = Orientation.Vertical;
            newContainer.SizeInfo.AbsoluteSize = new Size(10, 10);
            for (int j = 0; j < cols; j++)
            {
                SplitPanel panel = CreateSplitPanel();
                panel.SizeInfo.AbsoluteSize = new Size(10, 10);
                newContainer.SplitPanels.Add(panel);
            }
 
            container.SplitPanels.Add(newContainer);
        }
 
        if (centerFill)
        {
            SplitPanel centerPanel = (container.SplitPanels[rows / 2] as RadSplitContainer).SplitPanels[cols / 2];
            centerPanel.SizeInfo.SizeMode = Telerik.WinControls.UI.Docking.SplitPanelSizeMode.Fill;
            centerPanel.Controls.Add(new RadTextBoxControl() { Dock = DockStyle.Fill, Multiline = true });
        }
    }
 
    Random random = new Random();
    private SplitPanel CreateSplitPanel()
    {
        SplitPanel panel = new SplitPanel();
        Color back = Color.FromArgb(this.random.Next(155, 255), this.random.Next(155, 255), this.random.Next(155, 255));
        panel.SplitPanelElement.Fill.BackColor = back;
        panel.SplitPanelElement.Fill.GradientStyle = GradientStyles.Solid;
 
        return panel;
    }
}

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik

Tags
TextBox
Asked by
Garrett
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or