打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
IWindowsFormsEditorService 接口的VB.NET例子

IWindowsFormsEditorService 接口的VB.NET例子

[日期:2007-12-05]   来源:互联网整理  作者:佚名   [字体: ]
    新闻简介:下面的示例提供一个示例 UITypeEditor,它使用 IWindowsFormsEditorService 显示用于用户输入的 Form。
Imports System Imports System.ComponentModel Imports System.ComponentModel.Design Imports System.Drawing Imports System.Drawing.Design Imports S
        关 键 词:   windows 

下面的示例提供一个示例 UITypeEditor,它使用 IWindowsFormsEditorService 显示用于用户输入的 Form

Imports SystemImports System.ComponentModelImports System.ComponentModel.DesignImports System.DrawingImports System.Drawing.DesignImports System.Windows.FormsImports System.Windows.Forms.Design' Example UITypeEditor that uses the IWindowsFormsEditorService' to display a Form. Public Class TestDialogEditorInherits System.Drawing.Design.UITypeEditorPublic Sub New()End SubPublic Overloads Overrides Function GetEditStyle(ByVal context As System.ComponentModel.ITypeDescriptorContext) As System.Drawing.Design.UITypeEditorEditStyle' Indicates that this editor can display a Form-based interface.Return UITypeEditorEditStyle.ModalEnd FunctionPublic Overloads Overrides Function EditValue(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal provider As System.IServiceProvider, ByVal value As Object) As Object' Attempts to obtain an IWindowsFormsEditorService.Dim edSvc As IWindowsFormsEditorService = CType(provider.GetService(GetType(IWindowsFormsEditorService)), IWindowsFormsEditorService)If edSvc Is Nothing ThenReturn NothingEnd If' Displays a StringInputDialog Form to get a user-adjustable' string value.Dim form As New StringInputDialog(CStr(value))If edSvc.ShowDialog(form) = DialogResult.OK ThenReturn form.inputTextBox.TextEnd If' If OK was not pressed, return the original valueReturn valueEnd FunctionEnd Class' Example Form for entering a string.Friend Class StringInputDialogInherits System.Windows.Forms.FormPrivate ok_button As System.Windows.Forms.ButtonPrivate cancel_button As System.Windows.Forms.ButtonPublic inputTextBox As System.Windows.Forms.TextBoxPublic Sub New(ByVal [text] As String)InitializeComponent()inputTextBox.Text = [text]End SubPrivate Sub InitializeComponent()Me.ok_button = New System.Windows.Forms.Button()Me.cancel_button = New System.Windows.Forms.Button()Me.inputTextBox = New System.Windows.Forms.TextBox()Me.SuspendLayout()Me.ok_button.Anchor = System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.RightMe.ok_button.Location = New System.Drawing.Point(180, 43)Me.ok_button.Name = "ok_button"Me.ok_button.TabIndex = 1Me.ok_button.Text = "OK"Me.ok_button.DialogResult = System.Windows.Forms.DialogResult.OKMe.cancel_button.Anchor = System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.RightMe.cancel_button.Location = New System.Drawing.Point(260, 43)Me.cancel_button.Name = "cancel_button"Me.cancel_button.TabIndex = 2Me.cancel_button.Text = "Cancel"Me.cancel_button.DialogResult = System.Windows.Forms.DialogResult.CancelMe.inputTextBox.Location = New System.Drawing.Point(6, 9)Me.inputTextBox.Name = "inputTextBox"Me.inputTextBox.Size = New System.Drawing.Size(327, 20)Me.inputTextBox.TabIndex = 0Me.inputTextBox.Text = ""Me.inputTextBox.Anchor = System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.RightMe.ClientSize = New System.Drawing.Size(342, 73)Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.inputTextBox, Me.cancel_button, Me.ok_button})Me.MinimumSize = New System.Drawing.Size(350, 100)Me.Name = "StringInputDialog"Me.Text = "String Input Dialog"Me.ResumeLayout(False)End SubEnd Class' Provides an example control that displays instructions in design mode,' with which the example UITypeEditor is associated.Public Class WinFormsEdServiceDialogExampleControlInherits UserControl _Public Property TestDialogString() As StringGetReturn localDialogTestStringEnd GetSet(ByVal Value As String)localDialogTestString = ValueEnd SetEnd PropertyPrivate localDialogTestString As StringPublic Sub New()localDialogTestString = "Test String"Me.Size = New Size(210, 74)Me.BackColor = Color.BeigeEnd SubProtected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)If Me.DesignMode Thene.Graphics.DrawString("Use the Properties window to show", New Font("Arial", 8), New SolidBrush(Color.Black), 5, 5)e.Graphics.DrawString("a Form dialog box, using the", New Font("Arial", 8), New SolidBrush(Color.Black), 5, 17)e.Graphics.DrawString("IWindowsFormsEditorService, for", New Font("Arial", 8), New SolidBrush(Color.Black), 5, 29)e.Graphics.DrawString("configuring this control's", New Font("Arial", 8), New SolidBrush(Color.Black), 5, 41)e.Graphics.DrawString("TestDialogString property.", New Font("Arial", 8), New SolidBrush(Color.Black), 5, 53)Elsee.Graphics.DrawString("This example requires design mode.", New Font("Arial", 8), New SolidBrush(Color.Black), 5, 5)End IfEnd SubEnd Class

If you believe an article violates your rights or the rights of others, please contact us.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
在VB.NET中进行抓屏
在VB.Net中创建使用控件数组
如何使用Windows Media Encoder抓取摄象头视频并且保存为视频文件??
用VB.NET做WinForm的应用程序(To do with VB.NET WinFor...
VB.NET编程之透明窗体篇
如何用VB.Net创建一个三层的数据库应用程序
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服