Example #1
0
        public Button AddNewButton(Question question)
        {
            var btn = new Button();

            this.Controls.Add(btn);
            flowLayoutPanel1.SetColumn(btn, 1);
            btn.Width     = 1000;
            btn.Height    = 40;
            btn.TextAlign = ContentAlignment.MiddleCenter;
            btn.Left      = 15;
            btn.Text      = question.questionText;
            A            += 1;
            var answ      = question.questionAnswers;
            var likeColor = question.questionLikes;

            if (likeColor.IsLessThan(0))
            {
                btn.BackColor = Color.Tomato;
            }
            else if (answ.IsGreaterThan(0))
            {
                btn.BackColor = Color.LightGreen;
            }
            btn.Click += delegate(object sender, EventArgs e)
            {
                button_click(sender, e, question);
                db.AddView(question);
            };
            return(btn);
        }