Skip to main content

How to: Create ButtonEdit Control in Code

The following code creates a ButtonEdit control and places it onto a panel:

The code changes the button collection as follows:

The example subscribes to the ButtonEdit.ButtonClick event to respond to button clicks.

ButtonEdit1_creating_example.gif

ButtonEdit btnEdit1 = new ButtonEdit();
btnEdit1.Width = 100;
btnEdit1.Properties.Buttons[0].Kind = ButtonPredefines.OK;
btnEdit1.Properties.Buttons.Add(new EditorButton(ButtonPredefines.Delete));
panel1.Controls.Add(btnEdit1);

btnEdit1.ButtonClick += BtnEdit1_ButtonClick;

private void BtnEdit1_ButtonClick(object sender, ButtonPressedEventArgs e) {
    ButtonEdit editor = sender as ButtonEdit;
    if(e.Button.Kind == ButtonPredefines.OK) {
        //...
    }
    if (e.Button.Kind == ButtonPredefines.Delete) {
        //...
    }
}