Reputation: 5238
I have problem when i try to show dialog. When i pass this
argument as parameter form is empty.
What i do:
In my GroupsForm.cs
form i create this method:
private void addGrupuBtn_Click(object sender, EventArgs e)
{
using (var add = new GroupAdd(this))
{
add.ShowDialog();
}
}
In GroupAdd.cs
form i try to inject GroupsForm.cs
via constructor
public partial class GroupAdd : Form
{
private GrupeForm grupeForm;
public GroupAdd()
{
InitializeComponent();
}
public GroupAdd(GrupeForm groups) {
grupeForm = groups;
}
}
When i call default constructor without this
all controls inside form is rednered.
This work ok.
using (var add = new GroupAdd())
Upvotes: 0
Views: 1121
Reputation: 33391
You should call parameterless (default) ctor as well to initialize your controls.
public GroupAdd(GrupeForm groups)
: this()
{
grupeForm = groups;
}
Upvotes: 3
Reputation: 1263
You forgot to call InitializeComponent()
in your constructor, that's why it doesn't work.
Modify your code to this:
public GroupAdd(GrupeForm groups) {
grupeForm = groups;
InitializeComponent();
}
Upvotes: 3