Icone dans un Bouton

Résolu
KIPRE74 Messages postés 120 Date d'inscription jeudi 15 mai 2008 Statut Membre Dernière intervention 21 novembre 2013 - 31 juil. 2008 à 12:17
KIPRE74 Messages postés 120 Date d'inscription jeudi 15 mai 2008 Statut Membre Dernière intervention 21 novembre 2013 - 31 juil. 2008 à 14:23
Bonjour à tous !

Quelqu'un peut-il m'expliquer comment inserrer une icône dans un bouton ?

Merci d'avance

9 réponses

Utilisateur anonyme
31 juil. 2008 à 12:46
En, effet, pas de propriété Image pour Windows Mobile
Suffit de refaire le contrôle :

Option Explicit On
Option Strict On
Option Infer Off

Imports System.Drawing
Imports System.Windows.Forms

Public Class Button
  Inherits UserControl

  Private m_Image As Image
  Private m_BackColor As Color = SystemColors.Control
  Public Property Image() As Image
    Get
      Return m_Image
    End Get
    Set(ByVal value As Image)
      m_Image = value
    End Set
  End Property

  Public Overrides Property BackColor() As Color
    Get
      Return m_BackColor
    End Get
    Set(ByVal value As Color)
      m_BackColor = value
      MyBase.Invalidate()
    End Set
  End Property

  Private bPressed As Boolean

  Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
    bPressed = True
    MyBase.Invalidate()
    MyBase.OnMouseDown(e)
  End Sub
  Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
    bPressed = False
    MyBase.Invalidate()
    MyBase.OnMouseUp(e)
  End Sub
  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    If bPressed Then
      e.Graphics.FillRectangle(New SolidBrush(SystemColors.ControlDark), MyBase.ClientRectangle)
      e.Graphics.DrawRectangle(New Pen(SystemColors.ControlDarkDark), 0, 0, MyBase.ClientSize.Width - 1, MyBase.ClientSize.Height - 1)
    Else
      e.Graphics.DrawRectangle(New System.Drawing.Pen(SystemColors.ControlDark), 0, 0, MyBase.ClientSize.Width - 1, MyBase.ClientSize.Height - 1)
    End If
    If m_Image IsNot Nothing Then
      Dim ImgAttr As New Imaging.ImageAttributes()
      ImgAttr.SetColorKey(Color.White, Color.White)
      e.Graphics.DrawImage(m_Image, New Rectangle(CInt((MyBase.ClientSize.Width - m_Image.Width) / 2), CInt((MyBase.ClientSize.Height - m_Image.Height) / 2), m_Image.Width, m_Image.Height), 0, 0, m_Image.Width, m_Image.Height, GraphicsUnit.Pixel, ImgAttr)
    End If
    MyBase.OnPaint(e)
  End Sub

  Private Function SetColorAlpha(ByVal Color As Color, ByVal Alpha As Byte) As Color
    Return Color.FromArgb(System.BitConverter.ToInt32(New Byte() {Color.B, Color.G, Color.R, Alpha}, 0))
  End Function

End Class
<!-- Coloration syntaxique vb/vba/vb.net : http://charles.racaud.free.fr/code-syntaxing/ -->
Coloration syntaxique vb/vba/vb.net

__________
  Kenji
3
Utilisateur anonyme
31 juil. 2008 à 14:02
Ajoute un fichier de code (vide) à ton projet et colle s'y le code.
Ensuite, tu compile ton projet puis dans la boîte à outils, tu auras un nouveau composant button que tu pourra insérer sur ta form.

__________
  Kenji
3
Utilisateur anonyme
31 juil. 2008 à 12:23
Salut,

Avec sa proprité Image

__________
  Kenji
0
KIPRE74 Messages postés 120 Date d'inscription jeudi 15 mai 2008 Statut Membre Dernière intervention 21 novembre 2013
31 juil. 2008 à 12:31
Le Pb c'est que je voie nul part Image dans la liste des propriétes !!
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
KIPRE74 Messages postés 120 Date d'inscription jeudi 15 mai 2008 Statut Membre Dernière intervention 21 novembre 2013
31 juil. 2008 à 12:35
J'ai omis de dire que c'est du VB.Net pour Pocket PC
0
Utilisateur anonyme
31 juil. 2008 à 12:35
Tu est bien en vb.net ? (2002? 2003? 2005? 2008?)
Tu parle bien d'un Button : System.Windows.Forms.Button ?
__________
  Kenji
0
KIPRE74 Messages postés 120 Date d'inscription jeudi 15 mai 2008 Statut Membre Dernière intervention 21 novembre 2013
31 juil. 2008 à 12:42
Je parle bien du Button : System.Windows.Forms.Button

Lors que je vais sur les propriétés du bouton il n'y pas image; C'est un Visual Studio pr mobile
0
KIPRE74 Messages postés 120 Date d'inscription jeudi 15 mai 2008 Statut Membre Dernière intervention 21 novembre 2013
31 juil. 2008 à 13:02
Un peu trop compliqué à comprendre pour mon niveau.
Mon bouton se trouve sur un formulaire, ce code où le mettre ,
0
KIPRE74 Messages postés 120 Date d'inscription jeudi 15 mai 2008 Statut Membre Dernière intervention 21 novembre 2013
31 juil. 2008 à 14:23
Merci Charly !!!
ça marche très bien !
0
Rejoignez-nous