How I can Show the Value of Textbox in another form in C sharp?
-
Hi, I have a textbox, and i want to show the value of this textbox in another window form? Any one can help me? Thanks!
-
Hi, I have a textbox, and i want to show the value of this textbox in another window form? Any one can help me? Thanks!
Is this other form open already? Do you want the value to be displayed when the user clicks a button, or is it to be updated as the user types? You need to provide more information before anyone can offer useful help.
Forgive your enemies - it messes with their heads
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Is this other form open already? Do you want the value to be displayed when the user clicks a button, or is it to be updated as the user types? You need to provide more information before anyone can offer useful help.
Forgive your enemies - it messes with their heads
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
Yes, this form is already open, I wants to link it with this. And i want to open the this by button click,
-
Yes, this form is already open, I wants to link it with this. And i want to open the this by button click,
The common way to do this is to have an event in your code that looks something like this:
public event EventHandler<string> MyText;
protected void OnMyTextChanged()
{
EventHandler<string> handler = MyText;
if (handler == null)
{
return;
}
handler(this, new TextChangedEventArgs(textBox.Text));
}Then, all you need do is subscribe to the event in the second form, and it will automatically receive the string whenever you raise this event (which you would trigger from your button click event). Note that TextChangedEventArgs is a custom event args class defined like this:
public class TextChangedEventArgs : EventArgs
{
public TextChangedEventArgs(string text) : base()
{
MyText = text;
}
public string MyText { get; private set; }
}Forgive your enemies - it messes with their heads
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Hi, I have a textbox, and i want to show the value of this textbox in another window form? Any one can help me? Thanks!
Use the customeventhandler functionality of .net
Varun Sareen (Dot Net Developer)