Hide

SftButton/OCX 3.0 - Button Control

Display
Print

Images Sample (C#)

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 - CSharp\Images\Form1.cs or C:\Program Files\Softelvdm\SftButton OCX 3.0\Samples\Visual Studio - CSharp\Images\Form1.cs (on 32-bit Windows versions).


private Size savedSize;
private Point savedLoc;

private void Form1_Load(object sender, System.EventArgs e)
{
    // 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
    axSftButtonCheck.AutoSize = SftButtonAutoSizeConstants.autosizeSftButtonLeftCenter;
#else
    axSftButtonCheck.CtlAutoSize = SftButtonAutoSizeConstants.autosizeSftButtonLeftCenter;
#endif
    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;
}

private void check1_CheckedChanged(object sender, System.EventArgs e)
{
    // enable/disable the control so the image changes
    axSftButton1.Enabled = !check1.Checked;
}

private void check2_CheckedChanged(object sender, System.EventArgs e)
{
    // resize the control
    if (check2.Checked) {
#if VisualStudio2003AndEarlier
        axSftButton2.AutoSize = SftButtonAutoSizeConstants.autosizeSftButtonLeftCenter;
#else
        axSftButton2.CtlAutoSize = SftButtonAutoSizeConstants.autosizeSftButtonLeftCenter;
#endif
    } else {
#if VisualStudio2003AndEarlier
        axSftButton2.AutoSize = SftButtonAutoSizeConstants.autosizeSftButtonNone;
#else
        axSftButton2.CtlAutoSize = SftButtonAutoSizeConstants.autosizeSftButtonNone;
#endif
        axSftButton2.Location = savedLoc;
        axSftButton2.Size = savedSize;
    }
}

private void CloseButton_ClickEvent(object sender, System.EventArgs e)
{
    Application.Exit();
}

private void axSftButtonCheck_ClickEvent(object sender, System.EventArgs e)
{
    // toggle the check box
    if (axSftButtonCheck.Image1.Appearance == SftPictureImageConstants.sftImageCheckboxYes)
        axSftButtonCheck.Image1.Appearance = SftPictureImageConstants.sftImageCheckboxNo;
    else
        axSftButtonCheck.Image1.Appearance = SftPictureImageConstants.sftImageCheckboxYes;
}

private void axSftButtonCheck_DblClick(object sender, System.EventArgs e)
{
    axSftButtonCheck_ClickEvent(null, null);
}

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