I need to open a FrmEscalacao that sends information of FrmAdmin to FrmEscalacao with a string called "time"
here is the code of FrmAdmin
public partial class FrmAdmin : Form
{
private string time;
public FrmAdmin(string time)
{
InitializeComponent();
this.time = time;
}
public void btnEscalar_Click(object sender, EventArgs e)
{
this.Hide();
FrmEscalacao f1 = new FrmEscalacao();
f1.ShowDialog();
}
}
here is the code of FrmEscalacao
public partial class FrmEscalacao : Form
{
public string time;
private void FrmEscalacao (string time)
{
InitializeComponent();
this.time = time;
SQLiteConnection ocon = new SQLiteConnection(Conexao.stringConexao);
DataSet ds = new DataSet();
ocon.Open();
SQLiteDataAdapter da = new SQLiteDataAdapter();
da.SelectCommand = new SQLiteCommand("Here is the SQL command");
DataTable table = new DataTable();
da.Fill(table);
BindingSource bs = new BindingSource();
bs.DataSource = table;
DataTimes.DataSource = bs;
ocon.Close();
}
And it returns an error at
private void FrmEscalacao (string time)
You can have only constructor matching the name of the class. If it's the declaration of the constructor, then it should be
public FrmEscalacao(string time) {...}
Constructors should not have any return type. And you shouldn't declare it private
, if it's going to be used to create an instanse of that type; it should be public
.
Then you should use it:
FrmEscalacao f1 = new FrmEscalacao("your time");
that is, you must specify the value for time
argument of type string
.
You need to pass an argument to the constructor.
So, either add another method as follows:
public FrmEscalacao()
{
//all your code
}
Also, change your constructor to public void on the constructor that takes an argument.
public FrmEscalacao(string time)
{
//all your code
}
Constructors automatically don't return anything, so you don't need to mark them void.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With