title: Color of the panel not changing on mouse hover
body: <p>I am trying to change the color of my panel dynamically on mouse hover in windows form. This is the code I have written so far:</p>
  <pre><code>for (int i = suppliers.Count - 1; i &gt;= 0; i--)
  {
     resultPanels[i].Parent = list;
     resultPanels[i].Dock = DockStyle.Top;
     deleteBtn[i].Parent = resultPanels[i];
     resultPanels[i].Controls.Add(deleteBtn[i]);
     deleteBtn[i].Visible = true;
     deleteBtn[i].Dock = DockStyle.Left;
     ModifyBtn[i].Parent = resultPanels[i];
     resultPanels[i].Controls.Add(ModifyBtn[i]);
     ModifyBtn[i].Visible = true;
     ModifyBtn[i].Dock = DockStyle.Left;
     …
     resultPanels[i].Height = 27;
     list.Controls.Add(resultPanels[i]);
     resultPanels[i].MouseEnter += (sender, EventArgs) =&gt; { NewPanel_MouseEnter(sender, EventArgs); };
     resultPanels[i].MouseLeave += (sender, EventArgs) =&gt; { NewPanel_MouseLeave(sender, EventArgs); };
  }
  
  private void NewPanel_MouseEnter(object sender, EventArgs e)
  {
      Panel pan = sender as Panel;
      ModifyBtn[resultPanels.IndexOf(pan)].Show();
      deleteBtn[resultPanels.IndexOf(pan)].Show();
      ((Control)sender).BackColor = Color.White;
  }
  
  private void NewPanel_MouseLeave(object sender, EventArgs e)
  {
      Panel pan = sender as Panel;
      ModifyBtn[resultPanels.IndexOf(pan)].Hide();
      deleteBtn[resultPanels.IndexOf(pan)].Hide();
      pan.BackColor = Color.Transparent;
  }
  </code></pre>
  <p>When I run my program nothing happens when my mouse hover over the panel. How can I fix this?</p>