Click here to Skip to main content
15,891,607 members
Home / Discussions / C#
   

C#

 
GeneralRe: Validation in Multilingual Application using c# Pin
0x3c017-Jul-09 0:27
0x3c017-Jul-09 0:27 
GeneralRe: Validation in Multilingual Application using c# Pin
Luc Pattyn17-Jul-09 0:35
sitebuilderLuc Pattyn17-Jul-09 0:35 
GeneralRe: Validation in Multilingual Application using c# Pin
0x3c017-Jul-09 1:18
0x3c017-Jul-09 1:18 
GeneralRe: Validation in Multilingual Application using c# Pin
Luc Pattyn17-Jul-09 1:23
sitebuilderLuc Pattyn17-Jul-09 1:23 
QuestionHow to access a file in different machine Pin
arun_pk16-Jul-09 23:10
arun_pk16-Jul-09 23:10 
AnswerRe: How to access a file in different machine Pin
Tom Deketelaere16-Jul-09 23:18
professionalTom Deketelaere16-Jul-09 23:18 
QuestionLoad Type in DLL in a different AppDomain Pin
Nandiator16-Jul-09 21:57
Nandiator16-Jul-09 21:57 
AnswerRe: Load Type in DLL in a different AppDomain Pin
JoeSharp16-Jul-09 22:16
JoeSharp16-Jul-09 22:16 
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 

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.