Recognizing sender button control in click event
You need to cast to the type of your custom class that has the Data field.
Something like:
YourCustomButton button = sender as YourCustomButton;
Assuming your custom button type is CustomButton
, you should do this instead:
CustomButton_Click(object sender, EventArgs e){
CustomButton button = sender as CustomButton;
if (button != null){
// Use your button here
}
}
If you dont want to set a variable the simple way to do is:
((CustomButton)sender).Click
or whatever you want.