Host custom control on a NToolbar (NMenuWindow) instance

Applies to: Nevron User Interface for .NET

How to host custom control on a NToolbar (NMenuWindow) instance?

You can achieve this with the help of a NControlHostCommand class. The following code demonstrates how to create and insert such a command:

[C#]
using System.Windows.Forms;
using Nevron.UI.WinForm.Controls;
...
private void CreateDateTimePickerCommand(NToolbar parent)
{
    //create the desired control
    NDateTimePicker picker = new NDateTimePicker();
      
    //create a host instance
    NControlHostCommand command = new NControlHostCommand();
      
    //specify preferred metrics of the control
    command.PreferredWidth = 100; command.PreferredHeight = 20;
      
    //specify what control is hosted by this command
    command.SetControl(picker);
      
    //add the command to the toolbar
    parent.Commands.Add(command);
}

[VB.NET]
Imports System.Windows.Forms
Imports Nevron.UI.WinForm.Controls
...
Private Sub CreateDateTimePickerCommand(parent As NToolbar)
    'create the desired control
    Dim picker As New NDateTimePicker()
  
    'create a host instance
    Dim command As New NControlHostCommand()
  
    'specify preferred metrics of the control
    command.PreferredWidth = 100
    command.PreferredHeight = 20
  
    'specify what control is hosted by this command
    command.SetControl(picker)
  
    'add the command to the toolbar
    parent.Commands.Add(command)
End Sub

Article ID: 89, Created On: 10/13/2010, Modified: 11/16/2010