The following example demonstrates how to create nested commands:
C# |
Copy Code
|
---|---|
//create a NToolbar object first NToolbar toolbar = new NToolbar(); toolbar.DefaultCommandStyle = CommandStyle.Text; //create a file command and add it to the toolbar NCommand fileCommand = new NCommand(); fileCommand.Properties.Text = "&File"; fileCommand.Properties.ShowArrowStyle = ShowArrowStyle.Never; toolbar.Commands.Add(fileCommand); //create some nested commands NCommand saveCommand = new NCommand(); saveCommand.Properties.Text = "Save"; fileCommand.Commands.Add(saveCommand); NCommand exitCommand = new NCommand(); exitCommand.Properties.Text = "E&xit"; fileCommand.Commands.Add(exitCommand); NCommand saveAsCommand = new NCommand(); saveAsCommand.Properties.Text = "&Save As"; saveCommand.Commands.Add(saveAsCommand); NCommand saveAllCommand = new NCommand(); saveAllCommand.Properties.Text = "Save &All"; saveCommand.Commands.Add(saveAllCommand); |
Visual Basic |
Copy Code
|
---|---|
'create a NToolbar object first Dim toolbar As NToolbar = New NToolbar() toolbar.DefaultCommandStyle = CommandStyle.Text 'create a file command and add it to the toolbar Dim fileCommand As NCommand = New NCommand() fileCommand.Properties.Text = "&File" fileCommand.Properties.ShowArrowStyle = ShowArrowStyle.Never toolbar.Commands.Add(fileCommand) 'create some nested commands Dim saveCommand As NCommand = New NCommand() saveCommand.Properties.Text = "Save" fileCommand.Commands.Add(saveCommand) Dim exitCommand As NCommand = New NCommand() exitCommand.Properties.Text = "E&xit" fileCommand.Commands.Add(exitCommand) Dim saveAsCommand As NCommand = New NCommand() saveAsCommand.Properties.Text = "&Save As" saveCommand.Commands.Add(saveAsCommand) Dim saveAllCommand As NCommand = New NCommand() saveAllCommand.Properties.Text = "Save &All" saveCommand.Commands.Add(saveAllCommand) |
The result from the example code above.