Click here to Skip to main content
15,900,724 members
Home / Discussions / C#
   

C#

 
GeneralRe: Using A Retrieved Type Pin
#realJSOP26-Jan-09 5:28
professional#realJSOP26-Jan-09 5:28 
GeneralRe: Using A Retrieved Type Pin
DaveyM6926-Jan-09 10:02
professionalDaveyM6926-Jan-09 10:02 
GeneralRe: Using A Retrieved Type Pin
DaveyM6926-Jan-09 4:11
professionalDaveyM6926-Jan-09 4:11 
AnswerRe: Using A Retrieved Type Pin
DaveyM6926-Jan-09 11:26
professionalDaveyM6926-Jan-09 11:26 
Questionİf one array Label Enabled=false Pin
ammoti24-Jan-09 1:51
ammoti24-Jan-09 1:51 
GeneralRe: İf one array Label Enabled=false Pin
Guffa24-Jan-09 9:12
Guffa24-Jan-09 9:12 
GeneralRe: İf one array Label Enabled=false Pin
ammoti24-Jan-09 10:52
ammoti24-Jan-09 10:52 
AnswerRe: İf one array Label Enabled=false Pin
Guffa24-Jan-09 12:19
Guffa24-Jan-09 12:19 
I don't know exactly what you are trying to do in this code:
for (int a = 0; a < tombala.Length; a++)
{
   do
   {
      GelenSayi = RastgeleSayi.Next(1, 90);
      SayiVar = false;
      for (int w = 0; w < tombala.Length; w++)
      {
         if (GelenSayi == tombala[w])
         {
            SayiVar = true; break;
         }
      }
   } while (SayiVar == true);
   tombala[a] = GelenSayi;
   for (int u = 0; u < this.Controls.Count; u++)
   {
      if (this.Controls[u] is Label)
      {
         this.Controls[u].Name = tombala[a].ToString();
      }
   }
}
l.Text = l.Name;

but all that code can be replaced with just this:
l.Text = RastgeleSayi.Next(1, 90).ToString();


This is what I guess you are trying to do. It picks a winning number, then 24 numbers to display as labels. If the winning number is among the 24, that label is disabled.

Random rnd = new Random();
int winner = rnd.Next(1, 90);
int[] numbers = new int[24];
for (int i = 0; i < 24; i++) {
	int number;
	bool done;
	do {
		number = rnd.Next(1, 90);
		done = true;
		for (int j = 0; j < i; j++) {
			if (number == numbers[j]) {
				done = false;
				break;
			}
		}
	} while (!done);
	numbers[i] = number;
	Label l = new Label();
	l.Top = 25 + (i / 6) * 30;
	l.Left = 25 + (i % 6) * 30;
	l.Text = number.ToString();
	l.Width = 30;
	l.Height = 30;
	l.BorderStyle = BorderStyle.FixedSingle;
	l.BackColor = Color.Aqua;
	l.ForeColor = Color.Gray;
	l.Enabled = (number != winner);
	this.Controls.Add(l);
}


Despite everything, the person most likely to be fooling you next is yourself.

GeneralRe: İf one array Label Enabled=false Pin
ammoti24-Jan-09 12:51
ammoti24-Jan-09 12:51 
GeneralRe: İf one array Label Enabled=false Pin
Guffa24-Jan-09 14:46
Guffa24-Jan-09 14:46 
Questionretrieving songs from database using voice input.. Pin
a4abhi24-Jan-09 1:39
a4abhi24-Jan-09 1:39 
AnswerRe: retrieving songs from database using voice input.. Pin
WebMaster26-Jan-09 3:25
WebMaster26-Jan-09 3:25 
GeneralRe: retrieving songs from database using voice input.. Pin
a4abhi11-Feb-09 7:30
a4abhi11-Feb-09 7:30 
Questionstring to array Pin
lawrenceinba24-Jan-09 1:12
lawrenceinba24-Jan-09 1:12 
AnswerRe: string to array Pin
User 665824-Jan-09 1:20
User 665824-Jan-09 1:20 
AnswerRe: string to array Pin
DaveyM6924-Jan-09 1:21
professionalDaveyM6924-Jan-09 1:21 
GeneralRe: string to array Pin
lawrenceinba24-Jan-09 1:55
lawrenceinba24-Jan-09 1:55 
AnswerRe: string to array [modified] Pin
Luc Pattyn24-Jan-09 2:09
sitebuilderLuc Pattyn24-Jan-09 2:09 
GeneralRe: string to array Pin
User 665824-Jan-09 2:17
User 665824-Jan-09 2:17 
QuestionIHTMLElement.id is empty Pin
FaroePigbear24-Jan-09 1:03
FaroePigbear24-Jan-09 1:03 
AnswerRe: IHTMLElement.id is empty Pin
FaroePigbear24-Jan-09 2:45
FaroePigbear24-Jan-09 2:45 
Questionunable to spot the error Pin
lawrenceinba24-Jan-09 0:48
lawrenceinba24-Jan-09 0:48 
AnswerRe: unable to spot the error Pin
User 665824-Jan-09 1:24
User 665824-Jan-09 1:24 
GeneralRe: unable to spot the error Pin
lawrenceinba24-Jan-09 1:44
lawrenceinba24-Jan-09 1:44 
GeneralRe: unable to spot the error Pin
User 665824-Jan-09 1:52
User 665824-Jan-09 1:52 

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.