Alternative TextBox - harborsiem/WinForms-Ribbon GitHub Wiki

TextBox

A TextBox is missing in the Microsoft implementation of the Ribbon Framework. But I think you can use a RibbonComboBox with the Markup Property IsEditable="true" as alternative.

Using TextBox – Ribbon Markup As always, a command should be defined:

<Command Name="cmdTextBox2" Id="1019" />

The views section:

<Application.Views>
  <Ribbon>
    <Ribbon.Tabs>
      <Tab>
        <Group>
          <ComboBox CommandName="cmdTextBox2"
                    IsAutoCompleteEnabled="true"
                    IsEditable="true"
                    ResizeType="NoResize" />
        </Group>
      </Tab>
    </Ribbon.Tabs>
  </Ribbon>
</Application.Views>

CSharp program fragment in RibbonItems.cs

public void Init()
{
  TextBox2.RepresentativeString = "XXXXXXXXXXX";
  TextBox2.ItemsSourceReady += TextBox2_ItemsSourceReady;
  TextBox2.SelectedIndexChanged += TextBox2_SelectedIndexChanged; //after text and return key, event is firing
}

private void TextBox2_ItemsSourceReady(object sender, EventArgs e)
{
  TextBox2.GalleryItemItemsSource.Add(new GalleryItemPropertySet() {  }); //For selecting an empty text
}

private void TextBox2_SelectedIndexChanged(object sender, GalleryItemEventArgs e)
{
    string stringValue = string.Empty;
    if (TextBox2.SelectedItem == -1)
    {
        stringValue = TextBox2.StringValue;
    }
}
⚠️ **GitHub.com Fallback** ⚠️