using system.Windows.Foerms;
namespace Form
{
public partial class dep1 : Usercontrol
public static dep1
instance;
public dep1()
{
InitializeComponent();
instance = this;
}
private void btn_Click(object sender, EventArgs e)
{
Form2.instance.name.Text = textbox1.Text;
}
}
// Second window form which I want to //pass my value from usercontrol //textbox and then pass with a button //to form2 to display on label is below
using system.Windows.Forms;
namespace Form
{
public partial class Form2 : Form
public static successful1 instance;
public Label name;
public dep1()
{
InitializeComponent();
instance = this;
name = label4
}
}
I need answer urgentlyI moved your posts to a new thread instead of hijacking the old thread. Thank you for posting your code in code tags.
I need answers urgentlyI moved your posts to a new thread instead of hijacking the old thread. Thank you for posting your code in code tags.
Did you read the link I recommended in the other thread where you ignored my telling you to start a new thread?
Anyway, here's two links for how to pass data around the right way in WinForms:
Managing Data Among Multiple Forms (Part 1)
Lots of people ask questions about how to pass data between forms. It’s a slightly tricky question to answer because there are several ways...jmcilhinney.blogspot.com
This didn't answer my question. Let me be more clear to you.where you ignored my telling you to start a new thread?
Anyway, here's two links for how to pass data around the right way in WinForms:
Managing Data Among Multiple Forms (Part 1)
Lots of people ask questions about how to pass data between forms. It’s a slightly tricky question to answer because there are several ways...jmcilhinney.blogspot.com
The Right Way To Get Values From Form1 To Form2 - C# Tutorials | Dream.In.Code
The Right Way to get Values from Form1 to Form2:www.dreamincode.net
namespace abc
{
public partial class usercontrol1 : Usercontrol
{
private static usercontrol1 _instance;
public static usercontrol1
{
get
{
If (_instance == null)
_instance = new usercontrol1 ();
return _instance;
}
}
public delegate void SubmitClickedHandler();
public usercontrol1 ()
{
InitializeComponent();
}
public event SubmitClickedHandler SumbitClicked;
protected virtual void onSumbitClicked()
{
If (SubmitClicked != null)
{
SubmitClicked();
}
}
private void btnpress_Click(object sender, EventArgs e)
{
//In here I also have my MySQL code that should be sent into the database once button is clicked
onSumbitClicked();
}
Public string name
{
get { return textbox1.Text; }
Set { textbox1.Text = value; }
}
}
}
Can you show me an example of a code with thesame multiple static usercontrol instances you compiled yourself? Thanks and God blessThe same principles apply whether you are going between forms, between controls, or between controls and forms.
Sure it does. You're just not paying attention. You're hacking your way through this and expecting us to fix your hack. That's not the way to do it. The fact that you have "static" user controls is ample evidence of that. There's no way that you should have a static field referring to a control. You should go back and read my blog posts, understand the principles and then reimplemnent your code from scratch based on those principles. Just do it right in the first place instead of doing it wrong and then wondering why it doesn't work.This didn't answer my question.