all groups > dotnet windows forms designtime > october 2006 >
You're in the

dotnet windows forms designtime

group:

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


Re: Explicit instantiation of UI editors from System.Drawing.Design namespace Bryan Phillips
10/27/2006 9:56:48 PM
dotnet windows forms designtime: 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



[quoted text, click to view]
Explicit instantiation of UI editors from System.Drawing.Design namespace Yuri O
10/27/2006 10:49:29 PM
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 :)
--
Thanks
- Yuri

Re: Explicit instantiation of UI editors from System.Drawing.Design namespace Yuri O
10/29/2006 2:33:42 PM
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

"Bryan Phillips" <bphillips@nospam.crowechizek.com.spammenot> wrote in
message news:uyXeoKh%23GHA.4388@TK2MSFTNGP02.phx.gbl...
[quoted text, click to view]

Re: Explicit instantiation of UI editors from System.Drawing.Design namespace Bryan Phillips
10/29/2006 4:26:05 PM
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




[quoted text, click to view]
Re: Explicit instantiation of UI editors from System.Drawing.Design namespace Yuri O
10/29/2006 9:34:44 PM
Hi Bryan,

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

Best Regards
- Yuri

"Bryan Phillips" <bphillips@nospam.crowechizek.com.spammenot> wrote in
message news:eCPSOb3%23GHA.2300@TK2MSFTNGP04.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button