Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
GeneralRe: plase help me to correct some codes Pin
Emmanuel Medina15-May-13 10:03
professionalEmmanuel Medina15-May-13 10:03 
GeneralRe: plase help me to correct some codes Pin
Jegan Thiyagesan16-May-13 1:46
Jegan Thiyagesan16-May-13 1:46 
QuestionInheritance WinForms Pin
Cynizm15-May-13 6:12
Cynizm15-May-13 6:12 
AnswerRe: Inheritance WinForms Pin
Pete O'Hanlon15-May-13 6:24
mvePete O'Hanlon15-May-13 6:24 
GeneralRe: Inheritance WinForms Pin
Cynizm15-May-13 6:59
Cynizm15-May-13 6:59 
GeneralRe: Inheritance WinForms Pin
Pete O'Hanlon15-May-13 7:15
mvePete O'Hanlon15-May-13 7:15 
GeneralRe: Inheritance WinForms Pin
Cynizm15-May-13 7:25
Cynizm15-May-13 7:25 
GeneralRe: Inheritance WinForms Pin
lukeer15-May-13 21:20
lukeer15-May-13 21:20 
I think you want something like this:
C#
public class Child : System.Windows.Forms.Form
{
    private int _privateField = 0;

    public int PublicProperty
    {
        get { return(_privateField); }
        set { _privateField = value; }
    }
}

public class Parent : System.Windows.Forms.Form
{
    private void SomeMethod
    {
        Child child = new Child();
        child.PublicProperty = 42;                  // Use public property to pass value

        child.ShowDialog();                         // Show child as modal dialog

        int processedValue = child.PublicProperty;  // Get result of child's processing

        child.Dispose();
    }
}


In the parent form, you create an instance of the child form and pass the initial integer value to it via its public property. The child form can then work with it in every way you can think of.
ShowDialog() is a blocking call. It returns when the child form closes. You can then still read from it until it is disposed. That way you can get the changed value of PublicProperty.

You can as well create multiple public properties. That could be necessary if child form's processing results in a value of different type than the input.

Ciao,


luker

AnswerRe: Inheritance WinForms Pin
Dave Kreskowiak15-May-13 6:53
mveDave Kreskowiak15-May-13 6:53 
GeneralRe: Inheritance WinForms Pin
Cynizm15-May-13 7:04
Cynizm15-May-13 7:04 
GeneralRe: Inheritance WinForms Pin
Dave Kreskowiak15-May-13 12:42
mveDave Kreskowiak15-May-13 12:42 
AnswerRe: Inheritance WinForms Pin
Abhinav S15-May-13 7:56
Abhinav S15-May-13 7:56 
QuestionConsuming REST service from C# code Pin
Subin Mavunkal15-May-13 4:21
Subin Mavunkal15-May-13 4:21 
AnswerRe: Consuming REST service from C# code Pin
Abhinav S15-May-13 7:52
Abhinav S15-May-13 7:52 
QuestionWin7 FolderBrowser on ext. Dev doesn't work Pin
boogey4all.beds14-May-13 22:46
boogey4all.beds14-May-13 22:46 
AnswerRe: Win7 FolderBrowser on ext. Dev doesn't work Pin
dusty_dex15-May-13 0:27
dusty_dex15-May-13 0:27 
GeneralMethod Not Returning a Value Pin
N8tiv14-May-13 19:34
N8tiv14-May-13 19:34 
AnswerRe: Method Not Returning a Value Pin
parths14-May-13 20:05
parths14-May-13 20:05 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan14-May-13 21:24
mveRichard MacCutchan14-May-13 21:24 
GeneralRe: Method Not Returning a Value Pin
N8tiv15-May-13 20:29
N8tiv15-May-13 20:29 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan15-May-13 21:46
mveRichard MacCutchan15-May-13 21:46 
GeneralRe: Method Not Returning a Value Pin
N8tiv15-May-13 23:10
N8tiv15-May-13 23:10 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan16-May-13 1:17
mveRichard MacCutchan16-May-13 1:17 
GeneralRe: Method Not Returning a Value Pin
N8tiv16-May-13 4:27
N8tiv16-May-13 4:27 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan16-May-13 5:02
mveRichard MacCutchan16-May-13 5:02 

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.