Good night.
I´m novate in c#.
I created one class,conexion to database and form need add the name to create button and insert in database.
Problem: How add the method to flowLayoutPanel1.Controls.Add and insert to database?
please help me with the solution.
Form
public partial class Form1 : Form
{
private void Form1_Load(object sender, EventArgs e)
{
}
private void Adc_Click(object sender, EventArgs e)
{
Cad Categoria = new Cad();
Categoria.Categoria = Adicionartxt.Text; //here comes with the button name, need textbox receives the name and create a button with the name of the textbox.
flowLayoutPanel1.Controls.Add(Categoria.Categoria); //problem is here,
int resultado = CategoriaDAL.AddCategoria(Categoria);
Adicionartxt.Clear();
Adicionartxt.Visible = false;
}
Class
class Cad
{
public Int64 Id { get; set; }
public String Categoria {get; set;}
public Cad() { }
public void Cad(Int64 pId, String pCategoria)
{
this.Id = pId;
this.Categoria = pCategoria;
}
}