Click here to Skip to main content
15,881,600 members
Home / Discussions / C#
   

C#

 
AnswerRe: ControlBox limiting. Pin
Luc Pattyn15-Oct-09 5:13
sitebuilderLuc Pattyn15-Oct-09 5:13 
GeneralRe: ControlBox limiting. Pin
Gregory Bryant15-Oct-09 5:15
Gregory Bryant15-Oct-09 5:15 
GeneralRe: ControlBox limiting. Pin
Saksida Bojan15-Oct-09 6:06
Saksida Bojan15-Oct-09 6:06 
QuestionPassing Label's Name within a Class outside of the Form [modified] Pin
yogi_bear_7915-Oct-09 4:58
yogi_bear_7915-Oct-09 4:58 
AnswerRe: Passing Label's Name within a Class outside of the Form Pin
Luc Pattyn15-Oct-09 5:20
sitebuilderLuc Pattyn15-Oct-09 5:20 
GeneralRe: Passing Label's Name within a Class outside of the Form Pin
yogi_bear_7915-Oct-09 5:47
yogi_bear_7915-Oct-09 5:47 
GeneralRe: Passing Label's Name within a Class outside of the Form Pin
Luc Pattyn15-Oct-09 5:55
sitebuilderLuc Pattyn15-Oct-09 5:55 
GeneralRe: Passing Label's Name within a Class outside of the Form Pin
yogi_bear_7915-Oct-09 6:23
yogi_bear_7915-Oct-09 6:23 
("here is my code, I get 'A' instead of the expected 'B', what's up?").

First off, I am not trying to offend. My task was to convert a VB program to C#. I have completed everything except this one task. I have written the code (with help from the forumn, books and the Web). I am completey self-taught, and as a Network/Server administrator rarely do I delve into codeing. Alas, I will always be a rookie in this area. In an effort to keep the posts minimal I have only included snippets that I thought relevant. While I am sure my program could be written better by someone with more experience it does indeed work. I continually learn new/better ways to improve my codeing.

I belive my code should be passing the labels name via an event back to the form. Below I have provided everything I think is needed to see my attempt, maybe someone can see what I am doing wrong.

namespace VDP
{
    public partial class frmMain : Form
    {
        private Poker poker;
        
         public frmMain()
        {
            InitializeComponent();
            poker = new Poker();
            poker.UpdateLabels += new EventHandler<LablesEventArgs>(poker_UpdateLabels);
        }

        void poker_UpdateLabels(object sender, LablesEventArgs e)
        {
            UpdateLbls(e.Lbl);
        }

        public void UpdateLbls(Label lbl)
        {
            lbl.ForeColor = Color.Yellow;
        }
     }
}

namespace VDP
{
public class LablesEventArgs : EventArgs
    {
        public LablesEventArgs(Label lbl)
        {
            Lbl = lbl;
        }

        public Label Lbl
        {
            get;
            private set;
        }
    }
}


namespace VDP
{
    class Poker{

        public event EventHandler<LablesEventArgs> UpdateLabels;

        void Results(Label lbl_1)
        {
            OnUpdateLabels(new LablesEventArgs(lbl_1));
        }

        protected virtual void OnUpdateLabels(LablesEventArgs e)
        {
            EventHandler<LablesEventArgs> eh = UpdateLabels;
            if (eh != null)
                eh(this, e);
        }

        public void Hand_Analyzer() 
        {
            frmMain Form1 = new frmMain();
            Results(Form1.Label1);
        }
     }
}

GeneralRe: Passing Label's Name within a Class outside of the Form Pin
Luc Pattyn15-Oct-09 6:56
sitebuilderLuc Pattyn15-Oct-09 6:56 
GeneralRe: Passing Label's Name within a Class outside of the Form Pin
yogi_bear_7915-Oct-09 7:58
yogi_bear_7915-Oct-09 7:58 
GeneralRe: Passing Label's Name within a Class outside of the Form Pin
Luc Pattyn15-Oct-09 8:24
sitebuilderLuc Pattyn15-Oct-09 8:24 
GeneralRe: Passing Label's Name within a Class outside of the Form Pin
yogi_bear_7915-Oct-09 8:44
yogi_bear_7915-Oct-09 8:44 
GeneralRe: Passing Label's Name within a Class outside of the Form Pin
Luc Pattyn15-Oct-09 9:05
sitebuilderLuc Pattyn15-Oct-09 9:05 
GeneralRe: Passing Label's Name within a Class outside of the Form Pin
yogi_bear_7915-Oct-09 10:43
yogi_bear_7915-Oct-09 10:43 
GeneralRe: Passing Label's Name within a Class outside of the Form Pin
Luc Pattyn15-Oct-09 10:55
sitebuilderLuc Pattyn15-Oct-09 10:55 
AnswerRe: Passing Label's Name within a Class outside of the Form Pin
Ravi Bhavnani15-Oct-09 5:37
professionalRavi Bhavnani15-Oct-09 5:37 
QuestionParse SQL and replace column name with another name Pin
AhmedMasum15-Oct-09 4:27
AhmedMasum15-Oct-09 4:27 
AnswerRe: Parse SQL and replace column name with another name Pin
PIEBALDconsult15-Oct-09 4:56
mvePIEBALDconsult15-Oct-09 4:56 
GeneralRe: Parse SQL and replace column name with another name Pin
AhmedMasum17-Oct-09 2:37
AhmedMasum17-Oct-09 2:37 
QuestionChange color of RibbonControl Pin
yogesh_softworld12315-Oct-09 3:47
yogesh_softworld12315-Oct-09 3:47 
AnswerRe: Change color of RibbonControl Pin
Henry Minute15-Oct-09 4:56
Henry Minute15-Oct-09 4:56 
QuestionLearning ForEach... Pin
JollyMansArt15-Oct-09 3:21
JollyMansArt15-Oct-09 3:21 
AnswerRe: Learning ForEach... Pin
VanityClaw15-Oct-09 3:47
VanityClaw15-Oct-09 3:47 
GeneralRe: Learning ForEach... Pin
JollyMansArt15-Oct-09 3:53
JollyMansArt15-Oct-09 3:53 
QuestionDual running application using same database Pin
dptalt15-Oct-09 2:38
dptalt15-Oct-09 2:38 

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.