private void btn_load_Click(object sender, EventArgs e) { MySqlConnection connection; var sql = String.Format("SELECT * FROM creature_ai_scripts WHERE creature_id = {0}", UInt32.Parse(tb_entry.Text)); try { connection = new MySqlConnection("server=127.0.0.1;uid=root;pwd=;database=world2;"); connection.Open(); MySqlCommand cmd = new MySqlCommand(sql, connection); var data = cmd.ExecuteReader(); if (!data.HasRows) return; while(data.Read()) { tc_content.TabPages.Add("AI"); var newTab = tc_content.TabPages[tc_content.TabCount - 1]; var aiTab = new AiTab(); aiTab.Dock = DockStyle.Fill; aiTab.FromDatabase(data); newTab.Controls.Add(aiTab); } } catch (MySqlException ex) { MessageBox.Show(ex.Message); } }
private void AddNewAiTab() { tc_content.TabPages.Add("AI"); var newTab = tc_content.TabPages[tc_content.TabCount - 1]; var aiTab = new AiTab(); aiTab.Dock = DockStyle.Fill; newTab.Controls.Add(aiTab); }