private void CreatingNewButtons()
{
int horizotal = 30;
int vertical = 30;
DataTable dt = Product.getAllProducts();
Button[] buttonArray = new Button[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
string name = dt.Rows[i][0].ToString();
string price = dt.Rows[i][1].ToString();
// byte[] getImg = dt.Rows[i][2];
buttonArray[i] = new Button();
buttonArray[i].Size = new Size(110, 110);
buttonArray[i].Location = new Point(horizotal, vertical);
buttonArray[i].Text = "" + name + " Rs :" + price + "";
if ((i == 5) || (i == 11) || (i == 17) || (i == 23) || (i == 29) ||
(i == 35)) //|| (i == 62) || (i == 71))
{
vertical = 30;
horizotal = horizotal + 130;//depaththe ida
}
else
vertical = vertical + 130;
tabControl1.TabPages[0].Controls.Add(buttonArray[i]);
tabPage1.AutoScroll = true;
}
}
Using this code I create the button array and set buttons text from database as above. Now I want to get that text to string when clicked a button.
sendervariable to evaluate the button which triggered the click event, using which you can inspect itsTextproperty.