Hide

SftButton/OCX 3.0 - Button Control

Display
Print

Images Sample (VB.NET)

This sample illustrates button states and images.

The source code is located at C:\Program Files (x86)\Softelvdm\SftButton OCX 3.0\Samples\Visual Studio - VB.NET\Images\Form1.vb or C:\Program Files\Softelvdm\SftButton OCX 3.0\Samples\Visual Studio - VB.NET\Images\Form1.vb (on 32-bit Windows versions).

Private savedSize As Size
Private savedLoc As Point

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ' save the button size to demonstrate auto-sizing
    savedSize = AxSftButton2.Size
    savedLoc = AxSftButton2.Location

    ' initialize a SftButton control to look like a check box
    AxSftButtonCheck.BorderAlways = False
#If VisualStudio2003AndEarlier Then
    AxSftButtonCheck.AutoSize = SftButtonAutoSizeConstants.autosizeSftButtonLeftCenter
#Else
    AxSftButtonCheck.CtlAutoSize = SftButtonAutoSizeConstants.autosizeSftButtonLeftCenter
#End If
    AxSftButtonCheck.Bounce = SftButtonBounceStyleConstants.bounceSftButtonNo
    AxSftButtonCheck.ButtonStyle = SftButtonStyleConstants.styleSftButtonNone
    AxSftButtonCheck.ClickStyle = SftButtonClickStyleConstants.clickstyleSftButtonPictures
    AxSftButtonCheck.HoverStyle = SftButtonHoverStyleConstants.hoverstyleSftButtonExact
    AxSftButtonCheck.Image1.Appearance = SftPictureImageConstants.sftImageCheckboxYes
    AxSftButtonCheck.Text = "A SftButton control that looks like a check box with a caption"
    AxSftButtonCheck.ShowFocus = False
End Sub

Private Sub check1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles check1.CheckedChanged
    ' enable/disable the control so the image changes
    AxSftButton1.Enabled = Not check1.Checked
End Sub

Private Sub check2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles check2.CheckedChanged
    ' resize the control
    If check2.Checked Then
#If VisualStudio2003AndEarlier Then
        AxSftButton2.AutoSize = SftButtonAutoSizeConstants.autosizeSftButtonLeftCenter
#Else
        AxSftButton2.CtlAutoSize = SftButtonAutoSizeConstants.autosizeSftButtonLeftCenter
#End If
    Else
#If VisualStudio2003AndEarlier Then
        AxSftButton2.AutoSize = SftButtonAutoSizeConstants.autosizeSftButtonNone
#Else
        AxSftButton2.CtlAutoSize = SftButtonAutoSizeConstants.autosizeSftButtonNone
#End If
        AxSftButton2.Location = savedLoc
        AxSftButton2.Size = savedSize
    End If
End Sub

Private Sub CloseButton_ClickEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles CloseButton.ClickEvent
    Application.Exit()
End Sub

Private Sub AxSftButtonCheck_ClickEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftButtonCheck.ClickEvent
    ' toggle the check box
    If AxSftButtonCheck.Image1.Appearance = SftPictureImageConstants.sftImageCheckboxYes Then
        AxSftButtonCheck.Image1.Appearance = SftPictureImageConstants.sftImageCheckboxNo
    Else
        AxSftButtonCheck.Image1.Appearance = SftPictureImageConstants.sftImageCheckboxYes
    End If
End Sub

Private Sub AxSftButtonCheck_DblClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftButtonCheck.DblClick
    AxSftButtonCheck_ClickEvent(Nothing, Nothing)
End Sub

Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.