VB .Net Problemas con boton personalizado
Publicado por ICC Jairo A. Segura Morales (3 intervenciones) el 12/04/2010 20:59:01
Hola amigos programadores:
Llevo poco tiempo en el maravilloso y fascinante entorno de desarrollo .Net y pretendo hacer un boton personalizado para una aplicacion que estoy desarrollando pero resulta que no puedo anexar mi control al ToolBox (donde se encuentran todos los controles del VS .NEt para ser agregados en los proyectos) y menos al Formulario. Trato de crear el boton mediante codigo pero no veo ninguna de las propiedades y metodos que tiene mi control mas que los de la clase Button pues de ahi se hereda anexo mi codigo y espero puedan ayudarme a corregirlo y orientarme y decirme donde esta mi error saludos
Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Namespace DSINCButton
Partial Public Class clsDSINCButton
Inherits Button
#Region "Variables"
Private imgPress As Image
Private imgOver As Image
Private imgNormal As Image
Private imgDeshabilitado As Image
Private totTooltip As New ToolTip()
Private strMensaje As String = ""
#End Region
#Region "Propiedades"
<Category("DSINC Propiedades")>
<Description("Tooltip que del Control")>
Public Property DSINCTooltip As String
Get
Return strMensaje
End Get
Set(ByVal value As String)
strMensaje = value
End Set
End Property
<Category("DSINC Propiedades")>
<Description("Imagen evento OnClick ó MouseDown")>
Public Property DSINCImgPress As Image
Get
Return imgPress
End Get
Set(ByVal value As Image)
imgPress = value
End Set
End Property
<Category("DSINC Propiedades")>
<Description("Imagen evento OnMouseOver")>
Public Property DSINCImgOver As Image
Get
Return imgOver
End Get
Set(ByVal value As Image)
imgOver = value
End Set
End Property
<Category("DSINC Propiedades")>
<Description("Imagen evento OnMouseLeave o estado normal del control")>
Public Property DSINCImgNormal As Image
Get
Return imgNormal
End Get
Set(ByVal value As Image)
imgNormal = value
End Set
End Property
<Category("DSINC Propiedades")>
<Description("Imagen estado Deshabilitado")>
Public Property DSINCImgDeshabilitado As Image
Get
Return imgDeshabilitado
End Get
Set(ByVal value As Image)
imgDeshabilitado = value
End Set
End Property
#End Region
#Region "Constructor"
Sub New()
MyBase.New()
End Sub
#End Region
#Region "Eventos y Métodos"
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
'Add your custom paint code here
End Sub
Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
MyBase.Image = imgPress
MyBase.OnClick(e)
End Sub
Protected Overrides Sub OnMouseHover(ByVal e As System.EventArgs)
MyBase.Image = imgOver
If Trim(strMensaje) <> "" Then totTooltip.SetToolTip(Me, strMensaje)
MyBase.OnMouseHover(e)
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
MyBase.Image = imgOver
MyBase.OnMouseLeave(e)
End Sub
Protected Overrides Sub OnMouseDown(ByVal mevent As System.Windows.Forms.MouseEventArgs)
MyBase.Image = imgPress
MyBase.OnMouseDown(mevent)
End Sub
Protected Overrides Sub OnCreateControl()
MyBase.OnCreateControl()
MyBase.Image = imgNormal
MyBase.FlatStyle = Windows.Forms.FlatStyle.Flat
MyBase.FlatAppearance.MouseDownBackColor = Color.Transparent
MyBase.FlatAppearance.MouseOverBackColor = Color.Transparent
MyBase.FlatAppearance.BorderSize = 0
MyBase.Width = imgNormal.Width
MyBase.Height = imgNormal.Height
End Sub
Protected Overrides Sub OnEnabledChanged(ByVal e As System.EventArgs)
MyBase.OnEnabledChanged(e)
If MyBase.Enabled Then
MyBase.Image = imgNormal
Else
MyBase.Image = imgDeshabilitado
End If
End Sub
#End Region
End Class
End Namespace
Llevo poco tiempo en el maravilloso y fascinante entorno de desarrollo .Net y pretendo hacer un boton personalizado para una aplicacion que estoy desarrollando pero resulta que no puedo anexar mi control al ToolBox (donde se encuentran todos los controles del VS .NEt para ser agregados en los proyectos) y menos al Formulario. Trato de crear el boton mediante codigo pero no veo ninguna de las propiedades y metodos que tiene mi control mas que los de la clase Button pues de ahi se hereda anexo mi codigo y espero puedan ayudarme a corregirlo y orientarme y decirme donde esta mi error saludos
Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Namespace DSINCButton
Partial Public Class clsDSINCButton
Inherits Button
#Region "Variables"
Private imgPress As Image
Private imgOver As Image
Private imgNormal As Image
Private imgDeshabilitado As Image
Private totTooltip As New ToolTip()
Private strMensaje As String = ""
#End Region
#Region "Propiedades"
<Category("DSINC Propiedades")>
<Description("Tooltip que del Control")>
Public Property DSINCTooltip As String
Get
Return strMensaje
End Get
Set(ByVal value As String)
strMensaje = value
End Set
End Property
<Category("DSINC Propiedades")>
<Description("Imagen evento OnClick ó MouseDown")>
Public Property DSINCImgPress As Image
Get
Return imgPress
End Get
Set(ByVal value As Image)
imgPress = value
End Set
End Property
<Category("DSINC Propiedades")>
<Description("Imagen evento OnMouseOver")>
Public Property DSINCImgOver As Image
Get
Return imgOver
End Get
Set(ByVal value As Image)
imgOver = value
End Set
End Property
<Category("DSINC Propiedades")>
<Description("Imagen evento OnMouseLeave o estado normal del control")>
Public Property DSINCImgNormal As Image
Get
Return imgNormal
End Get
Set(ByVal value As Image)
imgNormal = value
End Set
End Property
<Category("DSINC Propiedades")>
<Description("Imagen estado Deshabilitado")>
Public Property DSINCImgDeshabilitado As Image
Get
Return imgDeshabilitado
End Get
Set(ByVal value As Image)
imgDeshabilitado = value
End Set
End Property
#End Region
#Region "Constructor"
Sub New()
MyBase.New()
End Sub
#End Region
#Region "Eventos y Métodos"
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
'Add your custom paint code here
End Sub
Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
MyBase.Image = imgPress
MyBase.OnClick(e)
End Sub
Protected Overrides Sub OnMouseHover(ByVal e As System.EventArgs)
MyBase.Image = imgOver
If Trim(strMensaje) <> "" Then totTooltip.SetToolTip(Me, strMensaje)
MyBase.OnMouseHover(e)
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
MyBase.Image = imgOver
MyBase.OnMouseLeave(e)
End Sub
Protected Overrides Sub OnMouseDown(ByVal mevent As System.Windows.Forms.MouseEventArgs)
MyBase.Image = imgPress
MyBase.OnMouseDown(mevent)
End Sub
Protected Overrides Sub OnCreateControl()
MyBase.OnCreateControl()
MyBase.Image = imgNormal
MyBase.FlatStyle = Windows.Forms.FlatStyle.Flat
MyBase.FlatAppearance.MouseDownBackColor = Color.Transparent
MyBase.FlatAppearance.MouseOverBackColor = Color.Transparent
MyBase.FlatAppearance.BorderSize = 0
MyBase.Width = imgNormal.Width
MyBase.Height = imgNormal.Height
End Sub
Protected Overrides Sub OnEnabledChanged(ByVal e As System.EventArgs)
MyBase.OnEnabledChanged(e)
If MyBase.Enabled Then
MyBase.Image = imgNormal
Else
MyBase.Image = imgDeshabilitado
End If
End Sub
#End Region
End Class
End Namespace
Valora esta pregunta
0