Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
AnswerRe: Passing strings between windows forms Pin
Som Shekhar2-Mar-10 1:03
Som Shekhar2-Mar-10 1:03 
GeneralRe: Passing strings between windows forms Pin
Syed Shahid Hussain2-Mar-10 1:27
Syed Shahid Hussain2-Mar-10 1:27 
GeneralRe: Passing strings between windows forms Pin
OriginalGriff2-Mar-10 1:52
mveOriginalGriff2-Mar-10 1:52 
GeneralRe: Passing strings between windows forms Pin
Phil Saville2-Mar-10 2:28
Phil Saville2-Mar-10 2:28 
GeneralRe: Passing strings between windows forms Pin
Phil Saville2-Mar-10 2:46
Phil Saville2-Mar-10 2:46 
GeneralRe: Passing strings between windows forms Pin
Rasepretrep22-Mar-10 4:03
Rasepretrep22-Mar-10 4:03 
GeneralRe: Passing strings between windows forms Pin
Phil Saville2-Mar-10 4:18
Phil Saville2-Mar-10 4:18 
GeneralRe: Passing strings between windows forms Pin
OriginalGriff2-Mar-10 4:34
mveOriginalGriff2-Mar-10 4:34 
There are a number of things wrong here!
What happens if I click the button in form1, then the button in form2, then the button in form1 again, and so on?

Because you are creating a new instance of the other form when you press the button and hiding the current form, you just end up creating an infinite series of hidden forms. When you eventually close the displayed form, you application does not exit, but the user can't see anything on screen, and has no way to get back to any form from which he could actually close the app.

If you must do it that way, then Form1:
private void button1_Click(object sender, EventArgs e)
{
    Form2 f = new Form2();
    Hide();   // You don't need This.Hide() here - it is obvious what is hiding.
    f.ShowDialog();
    labelIWantDataIn.Text = f.Data;
    Show();
}
Form2:
private void button1_Click(object sender, EventArgs e)
{
    Close();
}
And provide a property to access the textbox text.

I would still do it via an event though!
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace

C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

AnswerRe: Passing strings between windows forms Pin
DX Roster4-Mar-10 18:38
DX Roster4-Mar-10 18:38 
QuestionExporting DataGridView to excel Pin
Hum Dum1-Mar-10 23:18
Hum Dum1-Mar-10 23:18 
AnswerRe: Exporting DataGridView to excel Pin
Rashmi_Karnam2-Mar-10 0:13
Rashmi_Karnam2-Mar-10 0:13 
AnswerRe: Exporting DataGridView to excel Pin
Dan Mos2-Mar-10 1:30
Dan Mos2-Mar-10 1:30 
GeneralRe: Exporting DataGridView to excel Pin
Hum Dum2-Mar-10 2:04
Hum Dum2-Mar-10 2:04 
GeneralRe: Exporting DataGridView to excel [modified] Pin
Dan Mos2-Mar-10 2:17
Dan Mos2-Mar-10 2:17 
QuestionControl Authoring OnPaint not working as expected Pin
TheFoZ1-Mar-10 22:54
TheFoZ1-Mar-10 22:54 
AnswerRe: Control Authoring OnPaint not working as expected Pin
OriginalGriff1-Mar-10 23:54
mveOriginalGriff1-Mar-10 23:54 
GeneralRe: Control Authoring OnPaint not working as expected Pin
TheFoZ1-Mar-10 23:56
TheFoZ1-Mar-10 23:56 
QuestionC# - Fill a .xlsx / .xls - file with data based on a grid Pin
Mschauder1-Mar-10 22:44
Mschauder1-Mar-10 22:44 
AnswerRe: C# - Fill a .xlsx / .xls - file with data based on a grid Pin
TheFoZ1-Mar-10 23:54
TheFoZ1-Mar-10 23:54 
AnswerRe: C# - Fill a .xlsx / .xls - file with data based on a grid Pin
Rashmi_Karnam2-Mar-10 0:17
Rashmi_Karnam2-Mar-10 0:17 
AnswerRe: C# - Fill a .xlsx / .xls - file with data based on a grid Pin
Dan Mos2-Mar-10 1:32
Dan Mos2-Mar-10 1:32 
QuestionConverting to Hex Pin
Deepak.Prahlad1-Mar-10 22:28
Deepak.Prahlad1-Mar-10 22:28 
AnswerRe: Converting to Hex Pin
Luc Pattyn1-Mar-10 22:47
sitebuilderLuc Pattyn1-Mar-10 22:47 
GeneralRe: Converting to Hex Pin
Deepak.Prahlad1-Mar-10 23:03
Deepak.Prahlad1-Mar-10 23:03 
GeneralRe: Converting to Hex Pin
Luc Pattyn1-Mar-10 23:14
sitebuilderLuc Pattyn1-Mar-10 23:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.