Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
195
Creating an Inherited Control from UltraTextEditor
posted

I created a webAddressTextBox with a SingleButtonRight EditorButton. When the button is pressed opens up IE and displays website....  This works fine at run time.

I am having problems with design time.  I added my EditorButton to the buttons right collection using a key ("Hyperlink").  I can add the control at design time and everything looks fine, I then resize the control as needed.  If I close the design view of the form and reopen I get an error stating that the "Hyperlink" key already exists.  (Before I added code for the key, every time I editied the form in the designer and then closed and reopend the form it would add a new editor button to the ButtonsRight collection.)

Code:

Imports Infragistics.Win.UltraWinEditors

Imports System.ComponentModel

 

Public Class CsiHyperlinkEditor

Inherits CsiTextBox

Private WithEvents hyperlinkButton As EditorButton

 

 

Private Sub OnHyperlinkEditorButtonClick(ByVal sender As Object, ByVal e As EditorButtonEventArgs)

Try

Process.Start(Me.Text)

Catch ex As Exception

MessageBox.Show("Unable to find " & Me.Text, "Unable to find", MessageBoxButtons.OK)

End Try

End Sub

Public Sub New()

MyBase.New()

' This call is required by the Windows Form Designer.

InitializeComponent()

hyperlinkButton = CType(MyBase.ButtonsRight(0), EditorButton)

If hyperlinkButton IsNot Nothing Then

AddHandler hyperlinkButton.Click, AddressOf Me.OnHyperlinkEditorButtonClick

End If

End Sub

'UserControl overrides dispose to clean up the component list.

<System.Diagnostics.DebuggerNonUserCode()> _

Protected Overrides Sub Dispose(ByVal disposing As Boolean)

Try

If disposing AndAlso components IsNot Nothing Then

components.Dispose()

End If

Finally

MyBase.Dispose(disposing)

End Try

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

<System.Diagnostics.DebuggerStepThrough()> _

Private Sub InitializeComponent()

components = New System.ComponentModel.Container()

CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()

Me.SuspendLayout()

If Me.DesignMode = False Then

Me.ButtonsRight.Clear()

 

 

 

If Me.ButtonsRight.Exists("Hyperlink") = False Then

Dim hyperlinkEditorButton As EditorButton = New EditorButton("Hyperlink")

Dim hyperlinkAppearance As Infragistics.Win.Appearance = New Infragistics.Win.Appearance

hyperlinkAppearance.Image = Global.Csi.CsiBaseForms.My.Resources.Resources.world

hyperlinkEditorButton.Appearance = hyperlinkAppearance

 

Me.ButtonsRight.Add(hyperlinkEditorButton)

 

End If

End If

CType(Me, System.ComponentModel.ISupportInitialize).EndInit()

Me.ResumeLayout()

End Sub

 

End Class