FileSelectionCtrl.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.ComponentModel;
  2. namespace qdr.app.tools.qfu.gui.Subforms.Common
  3. {
  4. public partial class FileSelectionCtrl : UserControl
  5. {
  6. public event EventHandler? SelectedFileChanged;
  7. [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
  8. public string Caption
  9. {
  10. get => lblText.Text;
  11. set => lblText.Text = value;
  12. }
  13. [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
  14. public string SelectedFile {
  15. get => tbSelectedPath.Text;
  16. set => tbSelectedPath.Text = value;
  17. }
  18. public FileSelectionCtrl()
  19. {
  20. InitializeComponent();
  21. }
  22. private void butSelect_Click(object sender, EventArgs e)
  23. {
  24. var dlg = new OpenFileDialog
  25. {
  26. Title = lblText.Text,
  27. Filter = "All files (*.*)|*.*",
  28. Multiselect = false,
  29. };
  30. if (dlg.ShowDialog() == DialogResult.OK)
  31. {
  32. SelectedFile = dlg.FileName;
  33. SelectedFileChanged?.Invoke(this, EventArgs.Empty);
  34. }
  35. }
  36. }
  37. }