Xceed Grid for WinForms v4.3 Documentation
Embedded controls

Welcome to Xceed Grid for WinForms v4.3 > Basic Concepts > Editor Controls > WinTextBox control > Embedded controls

Side buttons

WinButton controls can be added to the WinTextBox control using the SideButtons property. These buttons can only be docked to the left or right (default) of the WinTextBox control. For example, in the image below, 3 WinButton controls are added to the textbox control's SideButtons collection. For the purposes of this example, the buttons do not actually perform an action.

VB.NET
Copy Code
Dim textBox As New WinTextBox

Dim dropButton As New WinButton

dropButton.ButtonType = New ButtonType( ButtonBackgroundImageType.Combo, _

                                        ButtonImageType.ScrollDown )

textBox.DropDownButton = dropButton

dropButton.Width = 18

Dim browseButton As New WinButton( "..." )

browseButton.Width = 18

Dim helpButton As New WinButton( New ButtonType(ButtonBackgroundImageType.Close, _

                                                ButtonImageType.Help ) )

helpButton.Width = 18

helpButton.Dock = DockStyle.Left

textBox.SideButtons.Add( dropButton )

textBox.SideButtons.Add( browseButton )

textBox.SideButtons.Add( helpButton )

textBox.Location = New Point( 10, 10 )

Me.Controls.Add( textBox )
C#
Copy Code
WinTextBox textBox = new WinTextBox();

WinButton dropButton = new WinButton;

dropButton.ButtonType = new ButtonType( ButtonBackgroundImageType.Combo,

                                        ButtonImageType.ScrollDown );

textBox.DropDownButton = dropButton;

dropButton.Width = 18;

WinButton browseButton = new WinButton( "..." );

browseButton.Width = 18;

WinButton helpButton = new WinButton( new ButtonType( ButtonBackgroundImageType.Close,

                                                      ButtonImageType.Help ) );

helpButton.Width = 18;

helpButton.Dock = DockStyle.Left;

textBox.SideButtons.Add( dropButton );

textBox.SideButtons.Add( browseButton );

textBox.SideButtons.Add( helpButton );

textBox.Location = new Point( 10, 10 );

this.Controls.Add( textBox );

The WinButton controls that are added to the WinTextBox control using the SideButtons property are also added to, and can be accessed via, the control's Controls collection.

Embedding other controls

WinButton controls can be added to the left or right of the WinTextBox control's TextBoxArea via the SideButtons property. Other controls can be added to the WinTextBox control using its Controls collection. By default, any controls that are added to the WinTextBox control will be docked to the right of the WinTextBox control. However, the Dock property can be changed to any value other than DockStyle.None

For example, in the image below, a WinCheckBox control was added to the bottom of a WinTextBox control to enable/disable the WinTextBox's TextBoxArea.

VB.NET
Copy Code
Dim textBox As New WinTextBox

textBox.Size = New Size(150, 100)

textBox.TextBoxArea.Multiline = True   

Dim checkEnable As New WinCheckBox( "Enable textbox", CheckState.Checked )

checkEnable.Tag = textBox.TextBoxArea

checkEnable.Dock = DockStyle.Bottom

checkEnable.BackColor = SystemColors.Control

AddHandler checkEnable.CheckedChanged, AddressOf Me.EnableTextBox

textBox.Controls.Add( checkEnable )

textBox.Location = New Point( 10, 10 )

Me.Controls.Add( textBox )

Private Sub EnableTextBox( ByVal sender As Object, ByVal e As EventArgs )

     Dim checkBox As WinCheckBox = CType( sender, WinCheckBox )

     Dim textArea As TextBoxArea = CType( checkBox.Tag, TextBoxArea )

     textArea.Enabled = checkBox.Checked

End Sub
C#
Copy Code
WinTextBox textBox = new WinTextBox();

textBox.Size = new Size(150, 100);

textBox.TextBoxArea.Multiline = true;   

WinCheckBox checkEnable = new WinCheckBox( "Enable textbox", CheckState.Checked );

checkEnable.Tag = textBox.TextBoxArea;

checkEnable.Dock = DockStyle.Bottom;

checkEnable.BackColor = SystemColors.Control;

checkEnable.CheckedChanged += new EventHandler( this.EnableTextBox );

textBox.Controls.Add( checkEnable );

textBox.Location = new Point( 10, 10 );

this.Controls.Add( textBox );

private void EnableTextBox( object sender, EventArgs e )

{

     WinCheckBox checkBox = ( WinCheckBox )sender;

     TextBoxArea textArea = ( TextBoxArea )checkBox.Tag;

     textArea.Enabled = checkBox.Checked;

}