[Solved] Visual Studio C# and Bunifu UI, can’t find on click method


I hesitate to answer because the question is poorly worded and I’m not certain this is what you’re looking for, but here’s how to hook up a Click event to a control created in code:

var button = new Bunifu.Framework.UI.BunifuFlatButton();
button.Click += Button_Click;

In Visual studio, after you type the +=, pressing Tab will create the click event template for you:

private void Button_Click(object sender, EventArgs e)
{
    throw new NotImplementedException();
}

Then you just replace the throw line with whatever code you want to execute when your button is clicked.

An instance of the control whose event triggers this method is passed through the sender argument. A common way to get the instance inside the event is to check the type and cast it:

if(sender is BunifuFlatButton)
{
    var button = (BunifuFlatButton) sender;
    MessageBox.Show($"You clicked the button named '{button.Name}'");
}

4

solved Visual Studio C# and Bunifu UI, can’t find on click method