1
Yes it is adding duplicates - check this also
Accepted 0
Try...
Modify the code
And look what happens when you add 2 or more rows...
I can repair the problem, so it's done
Thanks a lot for your assistance
Grettings
0
do you mean
Form2 agregardatos closes and then cannot be used again ?
change
agregardatos.Close();
to
agregardatos.Hide();
0
Here is...
0
Stay here a moment...
In a moments I upload a project with my problem
0
Look at this
0
No, I have 2 forms
The UserControl have the datagrid with a DataSet and another things.
I use the XForm to insert a new row in the UserControl.
The data comes from the text boxes in the XForm
0
So you have 3 forms, user control, formX and Xform.
user control and Xform are already open ?
You want Xform textbox.text to be entered into database by clicking button on formX
0
I need the XForm because otherwise I will have many controls on the Control.
There is only 1 TextBox are like 15 ...
0
Why do you need formX
0
well I'll explain:
I am working with a database in this UserControl and I need a form to add data.
to that is this

Do you understand me?
0
Button 1 on formX is private - so you can't access it from form 1
Can you explain why you need to click FormX.button1 from form1
0
Oh sorry but doesn't work because the button have's another instructions... I forget it
I edit the code:
public partial class Expedientes : UserControl
{
FormX AddNewForm = new FormX();
private void button1_Click(object sender, EventArgs e)
{
AddNewForm.button1.Click+= new EventHandler(XEvent);
AddNewForm.Show();
}
private void button2_Click(object sender, EventArgs e)
{
AddNewForm.Close();
}
private void XEvent(object sender, EventArgs e)
{
this.textBox1.Text="Some Word";
}
}
0
public partial class Expedientes : UserControl
{
//FormX AddNewForm = new FormX();//1* move to button event
private void button1_Click(object sender, EventArgs e)
{
FormX AddNewForm = new FormX();
AddNewForm.Show();
}
private void button2_Click(object sender, EventArgs e)
{
AddNewForm.Close();//2* or use AddNewForm.Hide()
}
}