大佬教程收集整理的这篇文章主要介绍了清除PictureBox – c#,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是它的一些代码;
// Function to add PictureBox Controls private void AddControls(int cnumber) { imgArray = new System.Windows.Forms.PictureBox[cnumber]; // assign number array for (int i = 0; i < cnumber; i++) { imgArraY[i] = new System.Windows.Forms.PictureBox(); // Initialize one variable } // When call this function you determine number of controls } private void ImagesInFolder() { FileInfo FInfo; // Fill the array (imgName) with all images in any folder imgName = Directory.GetFiles(Application.StartupPath + @"\Images"); // How many Picture files in this folder NumOfFiles = imgName.Length; imgExtension = new String[NumOfFiles]; for (int i = 0; i < NumOfFiles; i++) { FInfo = new FileInfo(imgName[i]); imgExtension[i] = FInfo.Extension; // We need to kNow the Extension // } } private void ShowFolderImages() { int Xpos = 8; int Ypos = 8; Image img; Image.GetThumbnailImageAbort myCallBACk = new Image.GetThumbnailImageAbort(ThumbnailCallBACk); MyProgress.Visible = true; MyProgress.Minimum = 1; MyProgress.Maximum = NumOfFiles; MyProgress.Value = 1; MyProgress.Step = 1; String[] Ext = new String [] {".GIF",".JPG",".bR_159_11845@P",".PNG"}; AddControls(NumOfFiles); for (int i = 0; i < NumOfFiles; i++) { switch (imgExtension[i].ToUpper()) { case ".JPG": case ".bR_159_11845@P": case ".GIF": case ".PNG": img = Image.FromFile(imgName[i]); // or img = new Bitmap(imgName[i]); imgArraY[i].Image = img.GetThumbnailImage(64,64,myCallBACk,IntPtr.Zero); img = null; if (Xpos > 432) // six images in a line { Xpos = 8; // leave eight pixels at Left Ypos = Ypos + 72; // height of image + 8 } imgArraY[i].Left = Xpos; imgArraY[i].Top = Ypos; imgArraY[i].Width = 64; imgArraY[i].Height = 64; imgArraY[i].Visible = true; // Fill the (tag) with name and full path of image imgArraY[i].Tag = imgName[i]; imgArraY[i].Click += new System.EventHandler(ClickImagE); this.BACkPanel.Controls.Add(imgArraY[i]); Xpos = Xpos + 72; // width of image + 8 Application.DoEvents(); MyProgress.PerformStep(); break; } } MyProgress.Visible = false; } private bool ThumbnailCallBACk() { return false; } private void btnLoad_Click(object sender,System.EventArgs E) { ImagesInFolder(); // Load images ShowFolderImages(); // Show images on PictureBox array this.Text = "Click wanted image"; }
我怎样才能做到这一点?
抱歉,我还没有重置按钮的任何代码.
我不知道该怎么做,我是c#的新手.
private void btnReset_Click(object sender,System.EventArgs E) { for(int x = this.BACkPanel.Controls.Count - 1; x >= 0; x--) { if(this.BACkPanel.Controls[x].GetType() == typeof(PictureBox)) this.BACkPanel.Controls.Remove(X); } for(int x = 0; x < imgArray.Length; x++) { imgArraY[x].Image = null; imgArraY[x] = null; } }
以上是大佬教程为你收集整理的清除PictureBox – c#全部内容,希望文章能够帮你解决清除PictureBox – c#所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。