Guest User

Guest User

  • Tech Writer
  • 529
  • 36.3k

Form 1 listbbox value pass in form 2 label “help Me In This Code”

Nov 4 2020 10:10 PM
 
Form 1 Code 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Threading.Tasks;  
  9. using System.Windows.Forms;  
  10. namespace WindowsFormsApp1  
  11. {  
  12. public partial class Form1 : Form  
  13. {  
  14. public Form1()  
  15. {  
  16. InitializeComponent();  
  17. }  
  18. string[] paths, files;  
  19. private void showform2_Click(object sender, EventArgs e)  
  20. {  
  21. Form2 f22 = new Form2();  
  22. f22.Show();  
  23. }  
  24. private void Form1_Load(object sender, EventArgs e)  
  25. {  
  26. }  
  27. private void listBox1_SelectedIndexChanged(object sender, EventArgs e)  
  28. {  
  29. }  
  30. private void btnopenfiles_Click(object sender, EventArgs e)  
  31. {  
  32. OpenFileDialog ofd = new OpenFileDialog();  
  33. ofd.Multiselect = true;  
  34. if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)  
  35. {  
  36. files = ofd.SafeFileNames;  
  37. paths = ofd.FileNames;  
  38. for(int i =0;i  
  39. {  
  40. listBox1.Items.Add(files[i]);  
  41. }  
  42. }  
  43. }  
  44. }  
  45. }  
 
 
Form 2 Code 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Threading.Tasks;  
  9. using System.Windows.Forms;  
  10. namespace WindowsFormsApp1  
  11. {  
  12. public partial class Form2 : Form  
  13. {  
  14. public Form2()  
  15. {  
  16. InitializeComponent();  
  17. }  
  18. }  
  19. }  

Attachment: Projects.rar

Answers (6)