Complete the following steps to add a standard TextBox control to a Ribbon group:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Public Class TextBoxHost Inherits C1.Win.C1Ribbon.RibbonControlHost Public Sub New() MyBase.New(New System.Windows.Forms.TextBox()) End Sub End Class |
To write code in C#
C# |
Copy Code
|
---|---|
public class TextBoxHost : C1.Win.C1Ribbon.RibbonControlHost { public TextBoxHost() : base(new System.Windows.Forms.TextBox()) { } } |
Tip: When you next add the TextBoxHost element you won't have to type its name. The name of this class will be available in the drop-down list in the Adding RibbonControlHost dialog box.
At run time, you will be able to interact with the TextBoxHost element as you would a standard TextBox.
The RibbonControlHost class publishes the standard properties and events of the hosted control. To access other properties, methods, and events of the hosted control use the RibbonControlHost.Control property.
It is also possible to override methods with events, such as OnSubscribeControlEvents, to handle events raised by the hosted control. You can add custom functionality into properties to enhance the hosted control.