Почему нельзя создать кнопку
LoadDB.в CS
public void Categories() { string query = "SELECT * FROM `categories` "; if (this.OpenConnection() == true) { LoadCat_frm LoadCat = new LoadCat_frm(); MySqlDataAdapter adapter = new MySqlDataAdapter(query, connection); DataTable dt = new DataTable(); DataSet ds = new DataSet(); adapter.Fill(dt); ds.Tables.Add(dt); int top = 0; int left = 4; foreach (DataRow dr in dt.Rows) { Button button = new Button(); button.FlatStyle = FlatStyle.Flat; button.BackColor = Color.Gold; button.Text = dr[1].ToString(); button.Font = new Font("Microsoft Sans Serif", 20, FontStyle.Bold); button.Size = new Size(170, 85); button.Left = left; button.Top = top; LoadCat_.panel1.Controls.Add(button); // here top += button.Height + 2; } } }
Форма form1.в CS
private void madeReq_frm_Load(object sender, EventArgs e) { dbConnect.Categories(); }
Что я уже пробовал:
я пытаюсь отделить класс и ОТ но после того как отделить это не работает