0

So i'm using a panel as a button. fairly easy but i have 3 or so labels in the panel and i have around 9 of these panel buttons. how can i make it a little easier than writing mouse enter and leave methods for each item?. if they where identical i would use a user control but there all different but i want the panels to be same colour on enter(silver) and the same on leave (green).

something like

if mouseenter panel1,label1,label2,label3 { panel1 silver } if that makes any sense

any help is appreciated.

  • You can map them to the same event handler and there discern them by the `sender` param.. – TaW May 20 '17 at 09:28
  • iv never used event handlers or senders but from what iv seen isnt that just about the same amount of code ? – Nathanial s-c May 20 '17 at 09:48
  • 1
    _iv never used event handlers or senders_ __Of course you have!__ By double clicking an event in the events pane of a control you have a) created and event handler (e.g. `private void button9_Click(object sender, EventArgs e)`) and hooked it up with the actual event (`button9.Click += button9_Click;` in the designer.cs file) See [here](http://stackoverflow.com/questions/33275763/copy-datagridview-values-to-textbox/33276161?s=14|0.0000#33276161) for more on this. This is basic c# coding knowledge. Do not miss it as it is essential! Several controls' events can be hooked up to the same handler! – TaW May 20 '17 at 10:10
  • 1
    i mean iv never used them "manually" but i did a quick test with a few random panels and labels and its worked perfect :D – Nathanial s-c May 20 '17 at 10:54

0 Answers0