Click here to Skip to main content
15,910,471 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# console application to dll and register..... Pin
DaveyM6914-Oct-09 8:38
professionalDaveyM6914-Oct-09 8:38 
GeneralRe: C# console application to dll and register..... Pin
greendragons14-Oct-09 8:46
greendragons14-Oct-09 8:46 
GeneralRe: C# console application to dll and register..... Pin
Dave Kreskowiak14-Oct-09 8:59
mveDave Kreskowiak14-Oct-09 8:59 
GeneralRe: C# console application to dll and register..... Pin
greendragons14-Oct-09 9:04
greendragons14-Oct-09 9:04 
QuestionProblem changing text on from lable from another class [modified] Pin
yogi_bear_7914-Oct-09 6:20
yogi_bear_7914-Oct-09 6:20 
AnswerRe: Problem changing text on from lable from another class Pin
Dave Kreskowiak14-Oct-09 6:38
mveDave Kreskowiak14-Oct-09 6:38 
GeneralRe: Problem changing text on from lable from another class Pin
yogi_bear_7914-Oct-09 8:02
yogi_bear_7914-Oct-09 8:02 
GeneralRe: Problem changing text on from lable from another class Pin
DaveyM6914-Oct-09 8:05
professionalDaveyM6914-Oct-09 8:05 
Here's a quick example of how it could be aproached using an event. An event is a delegate in disguise!
C#
using System;
using System.Windows.Forms;

namespace vdp
{
    public partial class FormMain : Form
    {
        private Poker poker;
        // using a local field but could be global
        private int credits;

        public FormMain()
        {
            InitializeComponent();
            poker = new Poker();
            labelWinnings.Text = "0";
            poker.UpdateWinnings += new EventHandler<WinningsEventArgs>(poker_UpdateWinnings);
            DoubleClick += new EventHandler(FormMain_DoubleClick);
        }

        void FormMain_DoubleClick(object sender, EventArgs e)
        {
            /* Every time form is double clicked game is played.
             * At the end of the game UpdateWinnings is raised */
            poker.PlayGame();
        }

        void poker_UpdateWinnings(object sender, WinningsEventArgs e)
        {
            AddToCredits(e.Winnings);
        }

        public void AddToCredits(int winnings)
        {
            credits += winnings;
            labelWinnings.Text = credits.ToString();
        }
    }

    public class Poker
    {
        public event EventHandler<WinningsEventArgs> UpdateWinnings;

        public void PlayGame()
        {
            // ...
            // Simulate Winning
            OnUpdateWinnings(new WinningsEventArgs(1000));
        }

        protected virtual void OnUpdateWinnings(WinningsEventArgs e)
        {
            EventHandler<WinningsEventArgs> eh = UpdateWinnings;
            if (eh != null)
                eh(this, e);
        }
    }

    public class WinningsEventArgs : EventArgs
    {
        public WinningsEventArgs(int winnings)
        {
            Winnings = winnings;
        }

        public int Winnings
        {
            get;
            private set;
        }
    }
}


Dave

Generic BackgroundWorker - My latest article!
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Why are you using VB6? Do you hate yourself? (Christian Graus)

GeneralRe: Problem changing text on from lable from another class Pin
yogi_bear_7914-Oct-09 8:42
yogi_bear_7914-Oct-09 8:42 
GeneralRe: Problem changing text on from lable from another class Pin
DaveyM6914-Oct-09 9:05
professionalDaveyM6914-Oct-09 9:05 
GeneralRe: Problem changing text on from lable from another class Pin
yogi_bear_7914-Oct-09 10:17
yogi_bear_7914-Oct-09 10:17 
QuestionPerform a mouse click Pin
p3rson14-Oct-09 6:11
p3rson14-Oct-09 6:11 
AnswerRe: Perform a mouse click Pin
Keith Barrow14-Oct-09 6:24
professionalKeith Barrow14-Oct-09 6:24 
AnswerRe: Perform a mouse click Pin
Luc Pattyn14-Oct-09 6:36
sitebuilderLuc Pattyn14-Oct-09 6:36 
QuestionCreate Singleton Class Different AppDomain Pin
dataminers14-Oct-09 5:36
dataminers14-Oct-09 5:36 
AnswerRe: Create Singleton Class Different AppDomain Pin
Not Active14-Oct-09 6:09
mentorNot Active14-Oct-09 6:09 
GeneralRe: Create Singleton Class Different AppDomain Pin
dataminers14-Oct-09 10:25
dataminers14-Oct-09 10:25 
GeneralRe: Create Singleton Class Different AppDomain Pin
Not Active14-Oct-09 10:50
mentorNot Active14-Oct-09 10:50 
GeneralRe: Create Singleton Class Different AppDomain Pin
dataminers14-Oct-09 12:02
dataminers14-Oct-09 12:02 
GeneralRe: Create Singleton Class Different AppDomain Pin
Not Active14-Oct-09 14:40
mentorNot Active14-Oct-09 14:40 
GeneralRe: Create Singleton Class Different AppDomain Pin
dataminers14-Oct-09 21:20
dataminers14-Oct-09 21:20 
GeneralRe: Create Singleton Class Different AppDomain Pin
Keith Barrow14-Oct-09 22:59
professionalKeith Barrow14-Oct-09 22:59 
GeneralRe: Create Singleton Class Different AppDomain Pin
dataminers15-Oct-09 0:47
dataminers15-Oct-09 0:47 
QuestionExcel and C# Pin
antsims14-Oct-09 5:14
antsims14-Oct-09 5:14 
AnswerRe: Excel and C# Pin
Dave Kreskowiak14-Oct-09 5:21
mveDave Kreskowiak14-Oct-09 5:21 

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.