Click here to Skip to main content
15,921,941 members
Home / Discussions / C#
   

C#

 
AnswerRe: Serial Communication (Loopback) Pin
led mike27-Jun-06 20:38
led mike27-Jun-06 20:38 
GeneralRe: Serial Communication (Loopback) Pin
Cadence2.028-Jun-06 5:39
Cadence2.028-Jun-06 5:39 
AnswerRe: Serial Communication (Loopback) Pin
Cadence2.028-Jun-06 6:24
Cadence2.028-Jun-06 6:24 
GeneralRe: Serial Communication (Loopback) Pin
led mike28-Jun-06 7:44
led mike28-Jun-06 7:44 
QuestionResolve UNC Names Pin
HahnTech27-Jun-06 12:13
HahnTech27-Jun-06 12:13 
AnswerRe: Resolve UNC Names Pin
Mike Poz27-Jun-06 14:12
Mike Poz27-Jun-06 14:12 
GeneralRe: Resolve UNC Names Pin
HahnTech27-Jun-06 18:44
HahnTech27-Jun-06 18:44 
GeneralRe: Resolve UNC Names Pin
Mike Poz28-Jun-06 8:13
Mike Poz28-Jun-06 8:13 
GeneralRe: Resolve UNC Names Pin
HahnTech28-Jun-06 8:30
HahnTech28-Jun-06 8:30 
QuestionInheritance Pin
Besinci27-Jun-06 11:24
Besinci27-Jun-06 11:24 
AnswerRe: Inheritance Pin
Wjousts27-Jun-06 11:31
Wjousts27-Jun-06 11:31 
GeneralRe: Inheritance Pin
Judah Gabriel Himango27-Jun-06 13:05
sponsorJudah Gabriel Himango27-Jun-06 13:05 
AnswerRe: Inheritance Pin
Elina Blank27-Jun-06 11:34
sitebuilderElina Blank27-Jun-06 11:34 
QuestionRe: Inheritance Pin
BoneSoft27-Jun-06 12:38
BoneSoft27-Jun-06 12:38 
Questionforms Pin
Mohammed Elkholy27-Jun-06 11:20
Mohammed Elkholy27-Jun-06 11:20 
AnswerRe: forms Pin
Jun Du27-Jun-06 13:36
Jun Du27-Jun-06 13:36 
QuestionHelp please: Naming the objects at runtime! Pin
Rojan Gh.27-Jun-06 11:17
professionalRojan Gh.27-Jun-06 11:17 
AnswerRe: Help please: Naming the objects at runtime! [modified] Pin
Wjousts27-Jun-06 11:28
Wjousts27-Jun-06 11:28 
AnswerRe: Help please: Naming the objects at runtime! Pin
Rojan Gh.28-Jun-06 2:35
professionalRojan Gh.28-Jun-06 2:35 
AnswerRe: Help please: Naming the objects at runtime! Pin
Guffa27-Jun-06 13:28
Guffa27-Jun-06 13:28 
AnswerRe: Help please: Naming the objects at runtime! Pin
Rojan Gh.28-Jun-06 2:48
professionalRojan Gh.28-Jun-06 2:48 
AnswerRe: Help please: Naming the objects at runtime! Pin
Guffa28-Jun-06 9:40
Guffa28-Jun-06 9:40 
AnswerRe: Help please: Naming the objects at runtime! [modified] Pin
Rojan Gh.28-Jun-06 12:08
professionalRojan Gh.28-Jun-06 12:08 
Yep, you are damn right!
I think I've got the point.
Thanx a million.Cool | :cool: Rose | [Rose] Smile | :)
I tried what you told and everything went right.Big Grin | :-D

Here is the code I wrote to solve the problem, do you like it?
PictureBox[,] pictureBoxes;

        private void Form1_Load(object sender, EventArgs e)
        {
            pictureBoxes = new PictureBox[20, 20];
            for (int x = 0; x < 20; x++)
            {
                for (int y = 0; y < 20; y++)
                {
                    pictureBoxes[x, y] = new PictureBox();
                    pictureBoxes[x, y].Name = "pictureBoxX" + x.ToString() + "Y" + y.ToString();
                    pictureBoxes[x, y].Width = 10;
                    pictureBoxes[x, y].Height = 10;
                    pictureBoxes[x, y].Left = x * 10;
                    pictureBoxes[x, y].Top = y * 10;
                    pictureBoxes[x, y].BorderStyle = BorderStyle.FixedSingle;
                    pictureBoxes[x, y].Click += new EventHandler(PictureBox_Click);
                    this.Controls.Add(pictureBoxes[x, y]);
                }
            }
        }

        void PictureBox_Click(object sender, EventArgs e)
        {
            PictureBox temp = (PictureBox)sender;
            ChangeColor(temp);
        }

        void ChangeColor(PictureBox pictureBox)
        {
            Random random = new Random();
            Bitmap bitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
            Graphics graphic = Graphics.FromImage(bitmap);
            SolidBrush brush = new SolidBrush(Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)));
            graphic.FillRectangle(brush, new Rectangle(0, 0, pictureBox.Width, pictureBox.Height));
            pictureBox.Image = bitmap;
        }



Sojaner!
AnswerRe: Help please: Naming the objects at runtime! Pin
Guffa28-Jun-06 20:14
Guffa28-Jun-06 20:14 
QuestionOpen Web form from Mdi form Pin
Saamir27-Jun-06 11:16
Saamir27-Jun-06 11:16 

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.