private void CreateButtons() { for (int i = 1; i <= MAXNUMCARDS; i ++) { btnList.Add(new Button()); btnList[i].FlatAppearance.BorderColor = System.Drawing.Color.Red; btnList[i].FlatAppearance.BorderSize = 0; btnList[i].FlatStyle = System.Windows.Forms.FlatStyle.Flat; btnList[i].Location = new System.Drawing.Point(5, 6); btnList[i].Name = "btnCard1"; btnList[i].Size = new System.Drawing.Size(95, 62); btnList[i].TabIndex = 0; btnList[i].UseVisualStyleBackColor = true; this.btnList[i].Click += new System.EventHandler(onButtonClick); } } private void onButtonClick(object source, int clickCount) { System.Console.Write("They clicked on button ${1}",btnList.FindIndex(source)); }