- Notifications
You must be signed in to change notification settings - Fork3
Create a custom cell editor and use it in a Property Grid.
License
DevExpress-Examples/winforms-property-grid-create-custom-editor
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This example demonstrates how to implement a UI Type Editor (FilteredFileNameEditor) and use it within the PropertyGridControl.
Create a
FilteredFileNameEditorclass and implement theUITypeEditor interface:internalclassFilteredFileNameEditor:UITypeEditor{privateOpenFileDialogofd=newOpenFileDialog();publicoverrideUITypeEditorEditStyleGetEditStyle(ITypeDescriptorContextcontext){returnUITypeEditorEditStyle.Modal;}publicoverrideobjectEditValue(ITypeDescriptorContextcontext,IServiceProviderprovider,objectvalue){ofd.FileName=value.ToString();ofd.Filter="Text File|*.txt|All Files|*.*";if(ofd.ShowDialog()==DialogResult.OK){returnofd.FileName;}returnbase.EditValue(context,provider,value);}}
Apply the
System.ComponentModel.Editorattribute as follows:publicclassFile{[System.ComponentModel.Editor(typeof(UIEditors.FilteredFileNameEditor),typeof(System.Drawing.Design.UITypeEditor))]publicstringPath{get;set;}publicstringPath2{get;set;}}
Assign a
ButtonEditto a cell as shown in the Assigning Editors to Editor Rows topic.privatevoidForm1_Shown(objectsender,EventArgse){RepositoryItemButtonEditedit=newRepositoryItemButtonEdit();edit.ButtonClick+=edit_ButtonClick;(this.propertyGridControl1.Rows[0]asCategoryRow).ChildRows["rowPath2"].Properties.RowEdit=edit;}
Handle the Button Editor's
ButtonClickevent.voidedit_ButtonClick(objectsender,DevExpress.XtraEditors.Controls.ButtonPressedEventArgse){this.openFileDialog1.ShowDialog();}
(you will be redirected to DevExpress.com to submit your response)
About
Create a custom cell editor and use it in a Property Grid.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.