User Interface for .NET / User's Guide / Custom Forms / Caption Buttons

Caption Buttons
 Overview
Being completely custom our forms allow you to specify your own caption buttons and to respond to their "Click" event. You may either specify and image set to be used by the button or to select a common glyph to be displayed.
 Adding Buttons

The following code demonstrates how to add custom caption button on a NForm instance:

C#
Copy Code
//create a frame caption button 
NFrameCaptionButton button = new NFrameCaptionButton();
button.Glyph = CommonGlyphs.PinDown;
button.GlyphSize = new Size(8, 10);

//create a new form and add our button to it
NForm form = new NForm();
form.CustomButtons.Add(button);
form.ShowDialog();
Visual Basic
Copy Code
'create a frame caption button 
Dim button As NFrameCaptionButton = New NFrameCaptionButton()
button.Glyph = CommonGlyphs.PinDown
button.GlyphSize = New Size(8, 10)

'create a new form and add our button to it
Dim form As NForm = New NForm()
form.CustomButtons.Add(button)
form.ShowDialog()

The result of the above code:

 

 Trapping The Click Event

The following example demonstrates how to trap a click from a custom caption button:

C#
Copy Code
NForm form = new NForm();
form.CaptionButtonClicked += new NUIItemEventHandler(OnCaptionButtonClicked);

...

private void OnCaptionButtonClicked(object sender, NUIItemEventArgs e)
{
    MessageBox.Show(e.Item.ToString());
}
Visual Basic
Copy Code
Dim form As NForm = New NForm()
AddHandler CaptionButtonClicked, AddressOf OnCaptionButtonClicked

...

Private Sub OnCaptionButtonClicked(ByVal sender As Object, ByVal e As NUIItemEventArgs) Handles form.CaptionButtonClicked
    MessageBox.Show(e.Item.ToString())
End Sub
 Remarks
Note that the CaptionButtonClicked event will be fired only for non-system (custom) buttons.
See Also