A few ignorant newbie questions

V

V. Jenks

Hi all,

I'm an accomplished web software engineer of 6 yrs. with
pretty tight knowledge of asp.net, however I'm entirely
ignorant when it comes to windows development and windows
forms.

There are a few basic questions which I'm sure could
easily be answered by any win forms developer:

1. How do you pass variable/property values between
forms? When I fill out a form on winForm1 how do I pass
those form values to winForm2? This is done a number of
ways on the "stateless" web but obviously the paradigm is
completely different in windows.

2. How can I launch winForm2 from winForm1 and then
immediately shut down winForm1 since I am finished with
it?

3. Can anyone point me to some simple articles on how to
make the DataGrid editable? How to customize column
headers? Other advanced DataGrid topics for Win Forms?

Thank you!

Vin
 
C

Chris Cummings

For item 1, I recommend creating properties for all inputs
and outputs for the form.

E.g.
form1:
private string pInput1;

public string Input1
{
set {
pInput1 = value;
}
}

public string Output1
{
get {
return ("Output value");
}
}

Then when launching the form:
form1 myForm = new form1();
myForm.Input1 = "Hello";
myForm.ShowDialog();
if (myForm.DialogResult == DialogResult.OK)
{
MessageBox.Show(myForm.Output1);
}

Regarding item 2:
I stay away from modeless dialogs. Besides, what if the
user cancels form 2? Then he/she can't get back to form 1.
 
R

Roy Osherove

1) Create public read-only properties on the form who's input you wish to
read from the other form.
2) If you're going to want to present only one screen at a time to the user,
it's usually preferable to go with a wizard style form. Consider using a
Tabbed dialog interface on the main form of the application.
If you want to create a dialog to present to the user, which retrieves
results and then the originator form does something with those results, it's
a good idea to keep Form1 open, and use Form2.ShowDialog(), which returns a
DialogResult enum result, allowing you to know whether the user has pressed
cancel or OK on the dialog form. Then you can simply read the public
properties of the dialog form(created like in advice no.1)
for some very good quickstart tutorials you can go here:
http://www.dotnetjunkies.com/quickstart/winforms/



2)A very good beginner's winform FAQ can be found here:
http://www.syncfusion.com/FAQ/Winforms/

it contains very good reference about DataGrids and lots of other stuff.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top