VIBlend
Home Products Downloads Purchase Support Forum About Blog

WinForms Button

by viblend 14. January 2012 21:24

To add a WinForms Button to your application you need to drag a new instance of the vButton Control from the Visual Studio Toolbox and drop it into your winforms application's form. Some of the frequently used properties such as TextAlign, ImageAlign and TextImageRelation allow you to easily change the layout of the Button's Text and Image. The VIBlend Button Control comes with 25 built-in Themes. It supports the new Metro Blue, Green and Orange themes and the popular Office Themes including the themes from Microsoft Office 2003, Office 2007 and Office 2010. You can easily change the winforms button theme. What you need to do is to just set the VIBlendTheme property and the winforms button will automatically change its visual appearance. Sometimes users want to customize a theme settings such as backcolor or forecolor. In this post we will create a custom Theme using the VIBlend Controls APIs and will apply it to the WinForms Button control.

- Define the theme colors. The colors array defines the default state colors, the highlightcolors array define the colors used when the mouse is over the button. The pressedcolors array defines colors used when the winforms button is pressed.

C#

Color[] colors = new Color[]{Color.FromArgb(255,39,94,176),
Color.FromArgb(255, 37, 92, 175), Color.FromArgb(255,51,105,206),
Color.FromArgb(255,53,135,226)};

Color[] highlightColors = new Color[]{Color.FromArgb(255,59,114,196),
Color.FromArgb(255, 57, 112, 185), Color.FromArgb(255,71,125,226),
Color.FromArgb(255,73,155,246)};

Color[] pressedColors = new Color[]{Color.FromArgb(255,79,134,216),
Color.FromArgb(255, 77, 132, 215), Color.FromArgb(255,91,145,246),
Color.FromArgb(255,93,175,255)};

VB .NET

Dim colors() As Color = {Color.FromArgb(255,39,94,176), Color.FromArgb(255, 37, 92, 175), Color.FromArgb(255,51,105,206), Color.FromArgb(255,53,135,226)}

Dim highlightColors() As Color = {Color.FromArgb(255,59,114,196), Color.FromArgb(255, 57, 112, 185), Color.FromArgb(255,71,125,226), Color.FromArgb(255,73,155,246)}

Dim pressedColors() As Color = {Color.FromArgb(255,79,134,216), Color.FromArgb(255, 77, 132, 215), Color.FromArgb(255,91,145,246), Color.FromArgb(255,93,175,255)}

- Define the default, highlight and pressed states. The following code illustrates how to create the styles for the winforms button states. The 90 number is for the gradient angle. This means that the button's gradient will be vertical. The 0.7f and 0.9f define the offset between each gradient color starting from 0 to 1. You can think about this as: 0f - first color, 0.7f - second color, 0.9f third color and 1.0f fourth gradient color.

C#

FillStyleGradientEx normalStyle = new FillStyleGradientEx(colors[0], colors[1],
    colors[2], colors[3], 90, 0.7f, 0.9f);

FillStyleGradientEx highlightStyle = new FillStyleGradientEx(highlightColors[0], highlightColors[1],
    highlightColors[2], highlightColors[3], 90, 0.7f, 0.9f);

FillStyleGradientEx pressedStyle = new FillStyleGradientEx(pressedColors[0], pressedColors[1],
    pressedColors[2], pressedColors[3], 90, 0.7f, 0.9f);

Color borderColor = Color.FromArgb(31, 72, 161);

VB .NET

Dim normalStyle As New FillStyleGradientEx(colors(0), colors(1), colors(2), colors(3), 90, 0.7f, 0.9f)

Dim highlightStyle As New FillStyleGradientEx(highlightColors(0), highlightColors(1), highlightColors(2), highlightColors(3), 90, 0.7f, 0.9f)

Dim pressedStyle As New FillStyleGradientEx(pressedColors(0), pressedColors(1), pressedColors(2), pressedColors(3), 90, 0.7f, 0.9f)

Dim borderColor As Color = Color.FromArgb(31, 72, 161)

- Create a ControlTheme instance and initialize its StyleNormal, StyleHighlight and StylePressed properties. The FillStyle member defines the background, BorderColor defines the border's color and TextColor defines the displayed text's color.

C#

ControlTheme theme = ControlTheme.GetDefaultTheme(VIBLEND_THEME.OFFICEBLUE).CreateCopy();

theme.StyleNormal.FillStyle = normalStyle;
theme.StyleNormal.BorderColor = borderColor;
theme.StyleNormal.TextColor = Color.White;

theme.StyleHighlight.FillStyle = highlightStyle;
theme.StyleHighlight.BorderColor = borderColor;
theme.StyleHighlight.TextColor = Color.White;

theme.StylePressed.FillStyle = pressedStyle;
theme.StylePressed.BorderColor = borderColor;
theme.StylePressed.TextColor = Color.White;

VB .NET

Dim theme As ControlTheme = ControlTheme.GetDefaultTheme(VIBLEND_THEME.OFFICEBLUE).CreateCopy()

theme.StyleNormal.FillStyle = normalStyle
theme.StyleNormal.BorderColor = borderColor
theme.StyleNormal.TextColor = Color.White

theme.StyleHighlight.FillStyle = highlightStyle
theme.StyleHighlight.BorderColor = borderColor
theme.StyleHighlight.TextColor = Color.White

theme.StylePressed.FillStyle = pressedStyle
theme.StylePressed.BorderColor = borderColor
theme.StylePressed.TextColor = Color.White

- The final step is to set the button's Theme property to point to the ControlTheme instance.

C#

this.vButton1.StyleKey = "ButtonNewStyle";
this.vButton1.Theme = theme;

VB .NET

Me.vButton1.StyleKey = "ButtonNewStyle"
Me.vButton1.Theme = theme

VIBlend WinForms Controls ver. 8.0

by viblend 8. November 2011 07:26

We are happy to announce the release of VIBlend WinForms Controls ver. 8.0. The new release features Metro UI themes in green, blue and red, ColorPicker DataGrid editor, DataGrid export to Excel improvements and several performance optimizations.

VIBlend Controls for WinForms v7.0

by viblend 5. July 2011 00:32

We are pleased to announce the availability of VIBlend Controls for WinForms ver. 7.0.

Highlights of the new features and improvements in the new version are:

  • New SplitContainer control.
  • New DataGridView Saving and restoring layout feature. This feature allows you to persist columns states between application runs.
  • New DataGridView Filtering options and APIs.
  • Improved TreeView loading performance.
  • Improved DataGridView Progress and ComboBox Editors rendering.

To download an evaluation version, please visit our Download page. 

VIBlend Controls for Windows Forms - ver. 6.0 Released

by viblend 27. February 2011 18:39

We are pleased to announce the availability of the VIBlend Controls for WinForms ver. 6.0.0. the next generation of user interface controls for Windows Forms from VIBlend.
This release features some important changes that you will want to check out.  The release notes provide a full list of all the changes, but we wanted to point out some key features.

Improved DataGridView: The DataGridView delivers extended filtering and localization options, enhanced Pivot-Design panel, Pivot-Table Totals and new cell editors.

Improved List Controls: The ComboBox and ListBox controls feature an improvement in the binding capabilities that will allow you to bind these controls to any data source. Another improvement is the enhanced styling that allows you to customize the look and feel of every list item.

Improved Styling and Appearance: In the continuous effort to make VIBlend WinForms controls meet your specific application needs, you will see improved styling features and API improvements across all controls.



If you want to check out the latest release, it is now available for download.

VIBlend extends the WinForms DataGridView with new features

by viblend 13. February 2011 08:44

The new version of VIBlend Controls for WinForms is coming in a few weeks and will deliver an upgrade to the DataGridView control with new features, better UI and styling capabilities.

-  Extended filtering options

The DataGridView filtering window will be extended by providing an easier and user-friendly experience. The new filtering window will show a checked list, allowing for single and/or multiple selections. The previous filtering mechanism will still be available and you will be able to switch to it by clicking a single button. The filtering improvements will also include new case-sensitive filtering options.



-    Improved support for Totals

The Pivot-Table totals support will be extended by adding a capability that will allow you to display Sub-Totals, Grand-Totals or a combination of Sub-Totals and Grand-Totals

-    New Cell Editors

The new version will include several new cell editors – Currency, Percentage, Number, Mask and Fixed-Point Editors

-    New Pivot-Table Filtering and enhanced Pivot-Design panel

The DataGridView will expose a new BoundFieldsFilters collection that will allow you to filter data in the Pivot-Table and display only a subset of data that meet the filtering criteria (criteria: Conditions you specify to limit which records are included in the result set of a filter.) that you specify and hides data that you do not want displayed. The Pivot-Design panel will feature a new Filter Area box that will enable you to manipulate the BoundFieldsFilters collection by drag and drop. Another addition to the Pivot-Design panel will be the Localization support.

Using VIBlend DataGridView for WinForms in a WPF Application

by viblend 3. April 2010 21:56

In this blog post we will show you how to use the VIBlend DataGridView for WinForms in a WPF application.

The following code example creates a WinForms DataGrid control with Office2010Black theme in a WPF application. This example uses a WindowsFormsHost element to place the DataGrid control within the main window’s root  element. The WindowsFormsHost element could be found in the WindowsFormsIntegration.dll.

[xaml]

  <Window x:Class="HostWinFormsControlInWPF.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:viblend="clr-namespace:VIBlend.WinForms.DataGridView;assembly=VIBlendGrid"
        Title="Window1" Height="300" Width="300">
    <Grid>
        <WindowsFormsHost>
            <viblend:vDataGridView x:Name="VIBlendDataGrid" VIBlendTheme="OFFICE2010BLACK"/>               
        </WindowsFormsHost>
    </Grid>
</Window>

In order to bind the data grid, you need to do the following:  Click on the Data menu item in your Visual Studio, then select the “Add new DataSource” item.  Browse to the Nwind.mdb which ships with the WinForms controls installation, choose the Employees table and click finish. In the code behind, after the InitializeComponent call or in the Load event handler , bind the data grid to the Employees table.

            NwindDataSet dataSet = new NwindDataSet();
            EmployeesTableAdapter adapter = new EmployeesTableAdapter();
            adapter.Fill(dataSet.Employees);
            this.VIBlendDataGrid.DataSource = dataSet.Employees.DefaultView;
            this.VIBlendDataGrid.DataBind();

Here is the result:

About the author

Some text that describes me

Tag cloud

Recent comments

Comment RSS
Copyright © 2011 VIBlend  
ALL RIGHTS RESERVED  
 
Terms of Use | Privacy Policy
WinForms Controls Purchase Online About Us
       
DataGrid Navigation Pane Technical Support Blog
ScrollBar TreeView
ListBox ProgressBar Downloads Register
ComboBox Buttons
TabControl Editors Documentation Client Login

VIBlend Blog is powered by BlogEngine.NET