//----------------------------------------------------------------------- private void colorizeRows() { bool switchColor = true; string lastGroup = ""; Color odd = Color.MintCream; Color even = Color.LightGray; foreach (Control i in panel2.Controls) { if (i is Panel) { tableRowTag tableRowTag = (tableRowTag)(((Panel)i).Tag); string currentGroup = (string)(tableRowTag.Get("Group")); //reassign if (currentGroup != lastGroup || currentGroup == null) { switchColor = !switchColor; } lastGroup = currentGroup; Color currntColor = (switchColor) ? odd : even; ((Panel)i).BackColor = currntColor; tableRowTag newTag = new tableRowTag(); newTag.Set("BgColor", currntColor); newTag.Set("Group", currentGroup); //reassign ((Panel)i).Tag = newTag; } } }
private void picBoxClickHighlightOff(object sender, EventArgs e) { string name = ((Control)sender).Name; Panel p = panel2.Controls.Find("panel" + name, true).FirstOrDefault() as Panel; tableRowTag tableRowTag = (tableRowTag)((Panel)p).Tag; Color prevColor = (Color)(tableRowTag.Get("BgColor")); p.BackColor = prevColor; }