本文介绍了Dyanamic按钮颜色变化不起作用。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果数据库状态包含yes,我尝试更改特定按钮颜色。但是它改变了所有按钮的颜色。



我尝试过:



i have try to change the specific button color,if the the database status contain yes. but it change all button color.

What I have tried:

Button newPanelcategory = new Button();

                newPanelcategory.Name = dt.Rows[i]["table_id"].ToString();
                newPanelcategory.Text = dt.Rows[i]["table_id"].ToString();
                newPanelcategory.Location = System.Drawing.Point.Add(new Point(0, 4 + i * 55), new Size(50, 50));
                newPanelcategory.Height = 50;
                newPanelcategory.Width = 75;
                newPanelcategory.FlatStyle = FlatStyle.Flat;
                newPanelcategory.Font = new Font("Times New Roman", 10, FontStyle.Bold);
                this.Controls.Add(newPanelcategory);
                flowLayoutPanel1.Controls.Add(newPanelcategory);
               newPanelcategory.BackColor = Color.Red;
                newPanelcategory.ForeColor = Color.White;
                newPanelcategory.Click += new EventHandler(newPanelcategory_Click);
                flowLayoutPanel1.AutoScroll = true;
                 DataTable dtms = blod.getallorder();
                for (int ia = 0; ia < dtms.Rows.Count; ia++)
                {
                    if ((dtms.Rows[ia]["active"]).ToString() == "yes")
                    {

                        newPanelcategory.BackColor =Color.Blue;

                    }
                    else
                    {
                        newPanelcategory.BackColor = Color.Red;

                    }
                }

            }

推荐答案


这篇关于Dyanamic按钮颜色变化不起作用。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:52
查看更多