// Please use the following namespace
// using System.Windows.Forms;
// using GrapeCity.Win.Editors;
// Defined a instance of GcTextBox type.
private GcTextBox gcTextBox1;
public void InitializeSideButtons()
{
// Create an instance of a GcTextBox control.
this.gcTextBox1 = new GcTextBox();
// Create a DropDownButton and wired the Click event.
DropDownButton dropDownBtn = new DropDownButton();
dropDownBtn.Click += new EventHandler(OnDropDownButtonClick);
// Forbid the default drop down behvior of the DropDownButton.
dropDownBtn.IsDefaultBehavior = false;
// Add this DropDownButton instance to the SideButtons collection.
this.gcTextBox1.SideButtons.Add(dropDownBtn);
}
/// <summary>
/// Called when the DropDownButton was clicked.
/// </summary>
private void OnDropDownButtonClick(object sender, EventArgs e)
{
// Overriden the default DropDown behavior of the DropDownButton.
// Allow show the drop down editor when ReadOnly, otherwise show a warning message box.
if (!this.gcTextBox1.ReadOnly)
{
// Invoke the Drop method to shown the DropDownEditor window.
this.gcTextBox1.Drop();
}
else
{
MessageBox.Show(this.gcTextBox1, "Could not open the drop down editor when GcTextBox is ReadOnly.");
}
}
' Please use the following namespace
' Imports System.Windows.Forms
' Imports GrapeCity.Win.Editors
' Defined a instance of GcTextBox type.
Private gcTextBox1 As GcTextBox
Public Sub InitializeSideButtons()
' Create an instance of a GcTextBox control.
Me.gcTextBox1 = New GcTextBox()
' Create a DropDownButton and wired the Click event.
Dim dropDownBtn As New DropDownButton()
AddHandler dropDownBtn.Click, AddressOf OnDropDownButtonClick
' Forbid the default drop down behvior of the DropDownButton.
dropDownBtn.IsDefaultBehavior = False
' Add this DropDownButton instance to the SideButtons collection.
Me.gcTextBox1.SideButtons.Add(dropDownBtn)
End Sub
''' <summary>
''' Called when the DropDownButton was clicked.
''' </summary>
Private Sub OnDropDownButtonClick(ByVal sender As Object, ByVal e As EventArgs)
' Overriden the default DropDown behavior of the DropDownButton.
' Allow show the drop down editor when ReadOnly, otherwise show a warning message box.
If Not Me.gcTextBox1.[ReadOnly] Then
' Invoke the Drop method to shown the DropDownEditor window.
Me.gcTextBox1.Drop()
Else
MessageBox.Show(Me.gcTextBox1, "Could not open the drop down editor when GcTextBox is ReadOnly.")
End If
End Sub