i add a button for each data row in a flowlayoutpanel with like
foreach (var Item in query.OrderBy(x=> x.menu_sort))
{
var btn = new Button
{
Name = Item.menu_name,
Text = Item.menu_description,
Tag = Item.menu_name,
Size = new Size(107, 50),
Font = new Font("B Nazanin",10)
};
MainPanel.Controls.Add(btn);
-----> i want to click on buttons and open a form. <-----
I think you want to add an event handler at runtime to a control, right? You can do it this way:
Then, you have to implement the method
button_Click
somewhere, with the correct signature: