So i successfully dynamiclly add button on DataGridView (DataGridViewButtonColumn) based on tables count in my database with :
//'cmd' type is MySqlCommand and 'cnnct' is MySqlConnection
//this is inside the Main()
string cmdString = "SHOW TABLES";
cmd.CommandText = cmdString;
cmd.Connection = cnnct;
Reader = cmd.ExecuteReader();
while (Reader.Read())
{
classSelect.Rows.Add(Reader.GetString(0));
}
Reader.Close();
then i've prepared a method that will be called when the button is clicked.
protected internal void FormCaller (object sender, EventArgs e)
{
//There's should be unique ID for the 'sender', but i don't know how
if(aioForm == null)
{
//'AIO_Form' is a Form
splash.ShowSplashScreen();
aioForm = new AIO_Form(this);
splash.CloseForm();
this.Visible = false;
aioForm.Visible = true;
}
//and some other code, handling if aioForm isn't null
}
The problem is, how i can add an EventHandler to the dynamiclly generated button, and it is based on a remote database ?
i've read from Here and Here (both are from StackOverflow) but no help.
Thanks in advance everybody.