Click here to Skip to main content
15,885,869 members
Home / Discussions / C#
   

C#

 
GeneralRe: Load Type in DLL in a different AppDomain Pin
Nandiator17-Jul-09 2:59
Nandiator17-Jul-09 2:59 
AnswerRe: Load Type in DLL in a different AppDomain Pin
PIEBALDconsult17-Jul-09 4:48
mvePIEBALDconsult17-Jul-09 4:48 
GeneralRe: Load Type in DLL in a different AppDomain Pin
Nandiator19-Jul-09 21:23
Nandiator19-Jul-09 21:23 
QuestionPassing values from one form to another form in C#.net using windows application Pin
elci16-Jul-09 21:23
elci16-Jul-09 21:23 
AnswerRe: Passing values from one form to another form in C#.net using windows application Pin
Manas Bhardwaj16-Jul-09 21:47
professionalManas Bhardwaj16-Jul-09 21:47 
AnswerRe: Passing values from one form to another form in C#.net using windows application Pin
musefan16-Jul-09 21:54
musefan16-Jul-09 21:54 
GeneralRe: Passing values from one form to another form in C#.net using windows application Pin
elci16-Jul-09 23:07
elci16-Jul-09 23:07 
AnswerRe: Passing values from one form to another form in C#.net using windows application Pin
DaveyM6916-Jul-09 22:37
professionalDaveyM6916-Jul-09 22:37 
To pass to a form that is a child (i.e. Form1 instanciates Form2 so Form2 is a child of Form1) use a property or method.
To pass from a child to a parent, use an event.
To pass between two children, use an event to notify the parent and the parent in turn uses a property/method to pass to the child.

The first two are in this example.
using System;
using System.Windows.Forms;

namespace ValuePassing
{
    public class FormParent : Form
    {
        public FormParent()
        {
            Shown += new EventHandler(FormParent_Shown);
        }

        void FormParent_Shown(object sender, EventArgs e)
        {
            FormChild formChild = new FormChild();
            formChild.ValueChanged += new EventHandler<ValueChangedEventArgs>(formChild_ValueChanged);
            formChild.VisibleToParentMethod(100);
            formChild.VisibleToParentProperty = 200;
        }

        void formChild_ValueChanged(object sender, ValueChangedEventArgs e)
        {
            Text = (string.Format("Value = {0}", e.Value));
        }
    }

    public class FormChild : Form
    {
        public event EventHandler<ValueChangedEventArgs> ValueChanged;

        private int visibleToParentValue;

        public int VisibleToParentProperty
        {
            get { return visibleToParentValue; }
            set
            {
                MessageBox.Show("Property");
                SetVisibleToParentValue(value);
            }
        }

        public void VisibleToParentMethod(int value)
        {
            MessageBox.Show("Method");
            SetVisibleToParentValue(value);
        }

        private void SetVisibleToParentValue(int value)
        {
            if (visibleToParentValue != value)
            {
                visibleToParentValue = value;
                OnVisibleToParentValueChanged(new ValueChangedEventArgs(value));
            }
        }

        protected virtual void OnVisibleToParentValueChanged(ValueChangedEventArgs e)
        {
            EventHandler<ValueChangedEventArgs> eh = ValueChanged;
            if (eh != null)
                eh(this, e);
        }
    }

    public class ValueChangedEventArgs : EventArgs
    {
        public ValueChangedEventArgs(int value)
        {
            Value = value;
        }
        public int Value
        {
            get;
            private set;
        }
    }
}


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus)

QuestionAdd myuserControl to Window Pin
Satish Pai16-Jul-09 21:06
Satish Pai16-Jul-09 21:06 
AnswerRe: Add myuserControl to Window Pin
Baeltazor16-Jul-09 23:27
Baeltazor16-Jul-09 23:27 
GeneralRe: Add myuserControl to Window Pin
Satish Pai17-Jul-09 1:21
Satish Pai17-Jul-09 1:21 
GeneralRe: Add myuserControl to Window Pin
Baeltazor18-Jul-09 0:51
Baeltazor18-Jul-09 0:51 
Question'Screen Capture' Performance Improvement Suggestions... Pin
Trapper-Hell16-Jul-09 20:35
Trapper-Hell16-Jul-09 20:35 
AnswerRe: 'Screen Capture' Performance Improvement Suggestions... Pin
stancrm16-Jul-09 20:40
stancrm16-Jul-09 20:40 
GeneralRe: 'Screen Capture' Performance Improvement Suggestions... Pin
Trapper-Hell16-Jul-09 21:50
Trapper-Hell16-Jul-09 21:50 
AnswerRe: 'Screen Capture' Performance Improvement Suggestions... Pin
Luc Pattyn17-Jul-09 0:46
sitebuilderLuc Pattyn17-Jul-09 0:46 
GeneralRe: 'Screen Capture' Performance Improvement Suggestions... Pin
Trapper-Hell17-Jul-09 2:28
Trapper-Hell17-Jul-09 2:28 
QuestionString and non english characters Pin
Imtiaz Murtaza16-Jul-09 20:24
Imtiaz Murtaza16-Jul-09 20:24 
AnswerRe: String and non english characters Pin
MarkB77716-Jul-09 20:36
MarkB77716-Jul-09 20:36 
GeneralRe: String and non english characters Pin
PIEBALDconsult17-Jul-09 4:52
mvePIEBALDconsult17-Jul-09 4:52 
GeneralRe: String and non english characters Pin
MarkB77717-Jul-09 14:26
MarkB77717-Jul-09 14:26 
AnswerRe: String and non english characters Pin
PIEBALDconsult17-Jul-09 4:55
mvePIEBALDconsult17-Jul-09 4:55 
GeneralRe: String and non english characters Pin
Imtiaz Murtaza17-Jul-09 7:12
Imtiaz Murtaza17-Jul-09 7:12 
GeneralRe: String and non english characters Pin
PIEBALDconsult17-Jul-09 7:22
mvePIEBALDconsult17-Jul-09 7:22 
QuestionAbout Microsoft ReportViewer Control in MSVS 2008 Pin
elci16-Jul-09 20:11
elci16-Jul-09 20:11 

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.