I have a custom set of UserControls: NavigationBar and NavigationItem.
I'd like that whenever the user clicks anywhere in the NavigationItem, an event is fired. I don't know how to set this up.
https://i.sstatic.net/ocP2D.jpg
I've tried this:
public partial class NavigationBar : UserControl { public NavigationBar() { InitializeComponent(); SetupEvents(); } public List<NavigationItem> NavigationItems { private get; set; } public NavigationItem SelectedItem { get; set; } private void SetupEvents() { navigationItem1.Click += new EventHandler(navigationItemClick); } void navigationItemClick(object sender, EventArgs e) { MessageBox.Show("Clicked on " + sender.ToString()); } } But that event only fires when the user specifically clicks on the NavigationItem control, but not when he clicks on the picture or text. (Those are PictureBox and Label).
What would be the best course of action? I'd like to create something well, not hacky code. Thanks!