私はpictureboxを動的に生成しています...今、私はその絵のボックスに別のイメージを表示しなければなりません。特定の絵のボックスをクリックすると、次のフォームの絵のボックスに表示されます。クリックして....どのように私はそれを行うことができます...私に返信..ありがとうアドバンス..
私のコーディングは
for(int i = 0; i
            shapes[i].Location = new Point(Left,Top);
            Left += 200;
            Top += i + 0;
            shapes[i].Size = new Size(150, 150);
            shapes[i].BackColor = Color.Black;
            shapes[i].Visible = true;
            shapes[i].BorderStyle = BorderStyle.FixedSingle;
            this.Controls.Add(shapes[i]);
            shapes[i].Click += new EventHandler(PictureBox_Click);                
        }
プライベートvoid PictureBox_Click(オブジェクト送信者、EventArgs e) {
        int imageid = 1;
        ClsProperty.ImageId = imageid;
        fd2 = new frmImageDisplay(imageid, ClsProperty.ipaddress);
        fd2.Show();
    }
                    
                
                
                                    
イベントハンドラの「送信者」は、クリックされた画像ボックスになります。
private void PictureBox_Click(object sender, EventArgs e) {
    PictureBox senderAsPictureBox = sender as PictureBox;
    //this is the picture box that got clicked
    int imageid = 1;
    ClsProperty.ImageId = imageid;
    fd2 = new frmImageDisplay(imageid, ClsProperty.ipaddress);
    fd2.Show();
}
                    
                                            
とにかくあなたのコードを表示するのが役に立ちますが、 ピクチャボックスを動的に作成する場合は、.Click + =メソッド名のようなコードを追加できます。これはもっと助けになるコントロールを追加するときに動的にイベントをコントロールに追加する方法について
それが役に立てば幸い
さて、私はそれが簡単だと思う、イベントの最初の引数は常にオブジェクトの送信者です、 ピクチャボックスオブジェクトにキャストしてIDプロパティを読み取ると、問題が発生しても前に進むことができます。