自定义用户控件编写——(文件夹目录选择)
由于最近接触项目中,选择目录较常用,先需要一个功能对其实现,具体如下
- 效果
源代码如下:
public partial class FolderButtonEdit : DevExpress.XtraEditors.ButtonEdit { public FolderButtonEdit() { InitializeComponent(); this.Properties.ReadOnly = true; ToolTip = "双击清空"; } protected override void OnClickButton(DevExpress.XtraEditors.Drawing.EditorButtonObjectInfoArgs buttonInfo) { base.OnClickButton(buttonInfo); FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == DialogResult.OK) { this.Text = fbd.SelectedPath; } } protected override void OnClick(EventArgs e) { base.OnClick(e); this.Text = null; } }