Click here to Skip to main content
15,913,773 members
Home / Discussions / C#
   

C#

 
GeneralRe: Label update Pin
imnotso#30-Jan-07 1:21
imnotso#30-Jan-07 1:21 
GeneralRe: Label update Pin
Martin#30-Jan-07 1:26
Martin#30-Jan-07 1:26 
GeneralRe: Label update [modified] Pin
Pete O'Hanlon30-Jan-07 2:05
mvePete O'Hanlon30-Jan-07 2:05 
AnswerRe: Label update Pin
Luc Pattyn30-Jan-07 2:05
sitebuilderLuc Pattyn30-Jan-07 2:05 
GeneralRe: Label update Pin
imnotso#30-Jan-07 2:12
imnotso#30-Jan-07 2:12 
GeneralRe: Label update Pin
Martin#30-Jan-07 2:20
Martin#30-Jan-07 2:20 
GeneralRe: Label update Pin
imnotso#30-Jan-07 2:42
imnotso#30-Jan-07 2:42 
GeneralRe: Label update Pin
Martin#30-Jan-07 2:55
Martin#30-Jan-07 2:55 
Ok,
I just whant to get you a little more help, to make your code alittle more dynamic.

What I would do, is to create my one labelclass which inherits from System.Windows.Forms.Label.
This class has just one member per default: Number (which is integer).
Like this:
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;

namespace WindowsApplication1
{
	public class CasinoLabel : System.Windows.Forms.Label
	{
		private System.ComponentModel.Container components = null;

		public CasinoLabel()
		{
			InitializeComponent();
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		private void InitializeComponent()
		{
			components = new System.ComponentModel.Container();
		}

		private int _number;
		[Browsable(true), Category("Casino")]
		public int Number
		{
			get
			{
				return _number;
			}
			set
			{
				_number = value;
			}
		}
	}
}

Now you can do much more fancy stuff with this class (I'm sure you will have a lot of ideas.)

Than place your new labels on your Form and set the Number Property over the designer.

In the Forms constructor you just have to search for your special Labels now and add them to a hashtable.
Like this:
private Hashtable CasinoLabels = new Hashtable();

public Form1()
{
    InitializeComponent();

    foreach(Control c in this.Controls)
    {
        CasinoLabel actlabel = c as CasinoLabel;
        if(actlabel != null)
        {
            CasinoLabels.Add(actlabel.Number, actlabel);
        }
    }
}


If you then whant to set youre text property over a random number just do this:
CasinoLabel randomLabel = CasinoLabels[randomnumber] as CasinoLabel;
randomLabel.Text = "1";


I just wanted to play around a little! Wink | ;)

All the best,

Martin
GeneralRe: Label update Pin
imnotso#30-Jan-07 4:00
imnotso#30-Jan-07 4:00 
GeneralRe: Label update Pin
Martin#30-Jan-07 4:05
Martin#30-Jan-07 4:05 
GeneralRe: Label update [modified] Pin
Luc Pattyn30-Jan-07 2:42
sitebuilderLuc Pattyn30-Jan-07 2:42 
AnswerRe: Label update Pin
Jasmine250130-Jan-07 5:53
Jasmine250130-Jan-07 5:53 
GeneralRe: Label update [modified] Pin
imnotso#30-Jan-07 6:13
imnotso#30-Jan-07 6:13 
GeneralRe: Label update Pin
Dan Neely30-Jan-07 6:45
Dan Neely30-Jan-07 6:45 
GeneralRe: Label update Pin
Jasmine250130-Jan-07 18:34
Jasmine250130-Jan-07 18:34 
GeneralRe: Label update Pin
Jasmine250130-Jan-07 18:39
Jasmine250130-Jan-07 18:39 
GeneralRe: Label update Pin
imnotso#30-Jan-07 23:17
imnotso#30-Jan-07 23:17 
Questionconvert c# to vb.net Pin
Doritkatz30-Jan-07 1:00
Doritkatz30-Jan-07 1:00 
AnswerRe: convert c# to vb.net Pin
andre_swnpl30-Jan-07 1:19
andre_swnpl30-Jan-07 1:19 
GeneralRe: convert c# to vb.net Pin
Doritkatz30-Jan-07 1:55
Doritkatz30-Jan-07 1:55 
AnswerRe: convert c# to vb.net Pin
Pete O'Hanlon30-Jan-07 1:20
mvePete O'Hanlon30-Jan-07 1:20 
GeneralRe: convert c# to vb.net Pin
Martin#30-Jan-07 1:32
Martin#30-Jan-07 1:32 
AnswerRe: convert c# to vb.net Pin
Dave Doknjas30-Jan-07 13:42
Dave Doknjas30-Jan-07 13:42 
QuestionSending a crypt Email with Attachment Pin
olivier29-Jan-07 23:37
olivier29-Jan-07 23:37 
QuestionGet File Name Pin
ParimalaRadjaram29-Jan-07 23:26
ParimalaRadjaram29-Jan-07 23:26 

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.