Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApp1
- {
- public partial class FileTextBox : UserControl
- {
- public string Path { get; set; }
- private TextBox tbPath;
- private Button btnSelect;
- public FileTextBox()
- {
- InitializeComponent();
- tbPath = new TextBox() { Dock = DockStyle.Fill, Location = new Point(0,0) };
- btnSelect = new Button { Dock = DockStyle.Right, Text = "...", Width=25 };
- btnSelect.Click += BtnSelect_Click;
- this.Controls.Add(tbPath);
- this.Controls.Add(btnSelect);
- }
- private void BtnSelect_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- var result = ofd.ShowDialog();
- if(result == DialogResult.OK)
- {
- tbPath.Text = ofd.FileName;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment