Hi, Create a class and a property like the following, I assuming you are having TabControl in Form1,
public static class SharedObjects
{
private static Form _objForm1;
public static Form objForm1
{
get { return _objForm1; }
set { _objForm1 = value; }
}
}
Now, just assign the reference of Form1 to objForm1 in Load event of Form1 like follows,
SharedObjects.objForm1 = this;
Now we have the reference of Form1 in SharedObjects class, we can use this anywhere inside the project. So you can access the tabcontrol in Form1 in Form2 like following,
cmd.Parameters.AddWithValue("@idempresa", SharedObjects.objForm1.YourTabControl.SelectedIndex);
Try this,