Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / October 2006

Tip: Looking for answers? Try searching our database.

Explicit instantiation of UI editors from System.Drawing.Design namespace

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Yuri O - 27 Oct 2006 20:49 GMT
Hello guys

Could you give me a clue how to explicitly use in code UI designers like
ImageEditors ( FontEditors, IconEditor) etc. like what the PropertGrid does?
I just want to implement some kind of light-weight propeditor but definitely
cannot imagine how to engage this functionality.
Probably there is any samples or any code related to such behavior... ?
Any help will be greatly appreciated :)
Signature

Thanks
- Yuri

Bryan Phillips - 27 Oct 2006 22:56 GMT
Here is a simple example to bring up a PageSettings dialog for a
property that returns PageSettings

   Public Class PageSettingsEditor
       Inherits System.Drawing.Design.UITypeEditor

       Public Overrides Function EditValue(ByVal context As
System.ComponentModel.ITypeDescriptorContext, ByVal provider As
System.IServiceProvider, ByVal value As Object) As Object
           Dim dialog As New System.Windows.Forms.PageSetupDialog()

           ' If PageSettings is null, calling ShowDialog will throw an
exception.
           If value Is Nothing Then
               dialog.PageSettings = New
System.Drawing.Printing.PageSettings()
           Else
               dialog.PageSettings = CType(value,
System.Drawing.Printing.PageSettings)
           End If

           ' If they clicked OK, return the new value
           If dialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
               Return dialog.PageSettings
           End If

           ' They did not click OK so don't change the value
           Return value
       End Function

       Public Overrides Function GetEditStyle(ByVal context As
System.ComponentModel.ITypeDescriptorContext) As
System.Drawing.Design.UITypeEditorEditStyle
           Return Drawing.Design.UITypeEditorEditStyle.Modal
       End Function
   End Class

On the property use the EditorAttribute class:

Public Class MyClass
       <Category("Print Setup")> _
       <Description("The collection of page settings.")> _
       <EditorBrowsable(EditorBrowsableState.Always)> _
       <EditorAttribute(GetType(PageSettingsEditor),
GetType(Drawing.Design.UITypeEditor))> _
       Public Property PageSettings() As PageSettings
           Get
               Return _pageSettings
           End Get
           Set(ByVal value As PageSettings)
               _pageSettings = value
           End Set
       End Property End Class

Bryan Phillips
MCSD, MCDBA, MCSE
Blog:  http://bphillips76.spaces.live.com

> Hello guys
>
[quoted text clipped - 7 lines]
> Thanks
> - Yuri
Yuri O - 29 Oct 2006 13:33 GMT
Thanks Bryan

It's interesting sample however I was wondering how to use UITypeEditors
explicitly i.e. without Propertygrid, let us say on-place in conjunction
with standard controls on a Form.

Thanks much!
Yuri

> Here is a simple example to bring up a PageSettings dialog for a property
> that returns PageSettings
[quoted text clipped - 67 lines]
>> Thanks
>> - Yuri
Bryan Phillips - 29 Oct 2006 17:26 GMT
In that case, you can use reflection to determine to look for the Editor
attribute for a class, create an instance of the editor, and call the
EditValue and GetEditStyle methods yourself while supplying the needed
parameters.

Bryan Phillips
MCSD, MCDBA, MCSE
Blog:  http://bphillips76.spaces.live.com

> Thanks Bryan
>
[quoted text clipped - 76 lines]
> >> Thanks
> >> - Yuri
Yuri O - 29 Oct 2006 20:34 GMT
Hi Bryan,

Thanks for effective advice, it seems you're right fully.

Best Regards
- Yuri

> In that case, you can use reflection to determine to look for the Editor
> attribute for a class, create an instance of the editor, and call the
[quoted text clipped - 88 lines]
>> >> Thanks
>> >> - Yuri

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.