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