VIBlend
Home Products Downloads Purchase Support Forum About Blog

Display a DataGridView in a Popup

by Admin 13. January 2012 22:48

In this post we will show you how to display the WinForms GridView in a Popup control. We will also use the new Metro Blue theme.

1. The first step is to drag and drop a new instance of the VIBlend DataGridView and the ControlBox control.
The ControlBox control is a control similar to the WinForms ComboBox, but it can display any content in its Popup.

2. The next step is to initialize the Grid. We will add 5 rows and 5 columns and will populate it in unbound mode. The first column will display images in the grid cells. The rest columns will be traditional text columns.

- Create the Grid Rows and Columns:

C#

for (int i = 0; i < 5; i++)
{
    Grid1.RowsHierarchy.Items.Add(i.ToString());
    Grid1.ColumnsHierarchy.Items.Add("Column " + i);
}

VB .NET

For i As Integer = 0 To 4
    Grid1.RowsHierarchy.Items.Add(i.ToString())
    Grid1.ColumnsHierarchy.Items.Add("Column " & i)
Next i

Fill the first grid column with images. In order to display an image in a grid cell, you need to do two things - set the cell's display settings to DisplaySettings.ImageOnly and call the SetCellImage method passing the cell's row, column and image index parameters.

C#

Grid1.ImageList = imageList1;
HierarchyItem columnImage = Grid1.ColumnsHierarchy.Items[0];

for (int i = 0; i < Grid1.RowsHierarchy.Items.Count; i++)
{
    HierarchyItem rowItem = Grid1.RowsHierarchy.Items[i];
    Grid1.CellsArea.SetCellDisplaySettings(rowItem, columnImage, DisplaySettings.ImageOnly);
    Grid1.CellsArea.SetCellImage(rowItem, columnImage, i);
}

VB .NET
 
Grid1.ImageList = imageList1
Dim columnImage As HierarchyItem = Grid1.ColumnsHierarchy.Items(0)

For i As Integer = 0 To Grid1.RowsHierarchy.Items.Count - 1
    Dim rowItem As HierarchyItem = Grid1.RowsHierarchy.Items(i)
    Grid1.CellsArea.SetCellDisplaySettings(rowItem, columnImage, DisplaySettings.ImageOnly)
    Grid1.CellsArea.SetCellImage(rowItem, columnImage, i)
Next i

Fill the rest of the columns by using the SetCellValue method.

C#

Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[0], Grid1.ColumnsHierarchy.Items[1], "Porsche Boxster");
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[1], Grid1.ColumnsHierarchy.Items[1], "Acura TL");
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[2], Grid1.ColumnsHierarchy.Items[1], "Audi A4");
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[3], Grid1.ColumnsHierarchy.Items[1], "BMW 645Ci");
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[4], Grid1.ColumnsHierarchy.Items[1], "BMW 760Li");

Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[0], Grid1.ColumnsHierarchy.Items[2], true);
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[1], Grid1.ColumnsHierarchy.Items[2], true);
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[2], Grid1.ColumnsHierarchy.Items[2], true);
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[3], Grid1.ColumnsHierarchy.Items[2], true);
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[4], Grid1.ColumnsHierarchy.Items[2], true);

Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[0], Grid1.ColumnsHierarchy.Items[3], "4 years");
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[1], Grid1.ColumnsHierarchy.Items[3], "4 years");
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[2], Grid1.ColumnsHierarchy.Items[3], "4 years");
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[3], Grid1.ColumnsHierarchy.Items[3], "4 years");
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[4], Grid1.ColumnsHierarchy.Items[3], "4 years");

Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[0], Grid1.ColumnsHierarchy.Items[4], "www.porsche.com");
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[1], Grid1.ColumnsHierarchy.Items[4], "www.acura.com");
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[2], Grid1.ColumnsHierarchy.Items[4], "www.audi.com");
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[3], Grid1.ColumnsHierarchy.Items[4], "www.bmw.com");
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items[4], Grid1.ColumnsHierarchy.Items[4], "www.bmw.com");

VB .NET

Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(0), Grid1.ColumnsHierarchy.Items(1), "Porsche Boxster")
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(1), Grid1.ColumnsHierarchy.Items(1), "Acura TL")
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(2), Grid1.ColumnsHierarchy.Items(1), "Audi A4")
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(3), Grid1.ColumnsHierarchy.Items(1), "BMW 645Ci")
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(4), Grid1.ColumnsHierarchy.Items(1), "BMW 760Li")

Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(0), Grid1.ColumnsHierarchy.Items(2), True)
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(1), Grid1.ColumnsHierarchy.Items(2), True)
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(2), Grid1.ColumnsHierarchy.Items(2), True)
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(3), Grid1.ColumnsHierarchy.Items(2), True)
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(4), Grid1.ColumnsHierarchy.Items(2), True)

Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(0), Grid1.ColumnsHierarchy.Items(3), "4 years")
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(1), Grid1.ColumnsHierarchy.Items(3), "4 years")
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(2), Grid1.ColumnsHierarchy.Items(3), "4 years")
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(3), Grid1.ColumnsHierarchy.Items(3), "4 years")
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(4), Grid1.ColumnsHierarchy.Items(3), "4 years")

Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(0), Grid1.ColumnsHierarchy.Items(4), "www.porsche.com")
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(1), Grid1.ColumnsHierarchy.Items(4), "www.acura.com")
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(2), Grid1.ColumnsHierarchy.Items(4), "www.audi.com")
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(3), Grid1.ColumnsHierarchy.Items(4), "www.bmw.com")
Grid1.CellsArea.SetCellValue(Grid1.RowsHierarchy.Items(4), Grid1.ColumnsHierarchy.Items(4), "www.bmw.com")

3. In order to display the Grid in the ControlBox's Popup,  you need to set the ControlBox's ContentControl property to point to the Grid instance.

C#

this.vControlBox.ContentControl = this.Grid1;

VB .NET

Me.vControlBox.ContentControl = Me.Grid1

 

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 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.

VIBlend WinForms Controls v5.0 - Released

by viblend 13. October 2010 21:39
We are pleased to announce the availability of the VIBlend Controls for WinForms ver. 5.0.0. the next generation of user interface controls for Windows Forms from VIBlend. The new release is expanding our commitment to business intelligence and data visualization by adding a Pivot Design panel. The Pivot Design panel integrates with VIBlend DataGrid for Windows Forms and provides an intuitive and easy to use drag and drop interface for defining pivot table views. You can choose the pivot rows, pivot colums, data fields and data aggregation functions.

Key benefits of the new release are:

- 2 new themes for all VIBlend WinForms Controls
- Pivot Design panel
- DataGrid Localization Provider
- Improved Ribbon Bar performance and rendering
- Quick Start projects now have a full support for VS 2010 which will decrease development time

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

What's new in VIBlend DataGridView for WinForms?

by viblend 13. July 2010 09:20

In the latest release of VIBlend Controls for WinForms, we introduced several new features in our DataGridView control. These are the Rows Grouping panel and the Column Chooser. The main purpose of the Rows Grouping panel is to allow you to easily group/ungroup columns via a built-in drag and drop and to visually represent the grouped columns.


The Column Chooser is an additional small feature which allows you to manage the visibility of your columns.  In order to activate the column chooser, set the EnableColumnChooser property to true. To show the column chooser, use the ShowColumnChooser method. If you want to hide it, use the HideColumnChooser method.



Another improvement in the DataGridView is the extended functionality of the ComboBox and DateTimePicker editors. Their pop up controls are now automatically opened when the editor is activated.  If you want to disable this feature, you can set the AutoOpenEditorOnActivation property of the editor to false.

TabControl for WinForms Updates

by viblend 3. May 2010 15:53

With version 4.6 of VIBlend Controls for WinForms, we introduced several rendering and functionality improvements and made the look and feel of VIBlend vTabControl fully customizable. You can easily add custom drawing by handling the DrawTabPage, DrawTabPageBackground and DrawTitleBackground events. The screenshot below is from our FlexibleStyling example (full source code available in C# and VB.NET):

We also added an easy way to customize the Font and Color settings of TabPage’s Header. Take a look at the code snippet and screenshot of a TabPage with green text color and bold font style.

           C#

vTabPage tabPage = this.vTabControl1.TabPages[0];
tabPage.UseThemeTextColor = false;
tabPage.UseDefaultTextFont = false;
tabPage.PressedTextColor = Color.Green;
tabPage.TextFont = new Font(tabPage.Font, FontStyle.Bold);
VB .NET
Dim tabPage As vTabPage = Me.vTabControl1.TabPages(0)
tabPage.UseThemeTextColor = False
tabPage.UseDefaultTextFont = False
tabPage.PressedTextColor = Color.Green
tabPage.TextFont = New Font(tabPage.Font, FontStyle.Bold)

 

 

Pivot Grid - Traditional vs Compact style layout

by viblend 18. April 2010 05:36

VIBlend DataGridView for WinForms offers multiple unique features that cannot be found in other Windows Forms data grid controls. These include multi-level hierarchies on rows and columns, rows grouping, pivot tables, and built-in OLAP capabilities. One of the main drawbacks of the traditional OLAP style rows layout is that it takes a lot of screen space. 

 

This could be improved by using the compact style layout. In this mode the rows of the pivot table are rendered in a tree-like structure.

 


Switching from default to compact style rendering is very easy. It requires setting the value of RowsHierarchy.CompactStyleRendering property to true:

C#
grid.RowsHierarchy.CompactStyleRenderingEnabled = true;
grid.RowsHierarchy.AutoResize();
grid.Invalidate();

VB .Net
grid.RowsHierarchy.CompactStyleRenderingEnabled = True
grid.RowsHierarchy.AutoResize()
grid.Invalidate()
 

You can switch between traditional and compact style rendering at runtime. The feature is also availalbe in VIBlend DataGrid for Silverlight.

Visual Studio 2010 and .Net Framework 4.0

by viblend 12. April 2010 03:22

VIBlend will fully support the .NET4 Client Profile in the next version of VIBlend Controls for WinForms which is expected in the middle of May. We will create a new VIBlend.WinForms.Controls.Design assembly and will move all the design time classes of our controls into it. The change is needed because the client profile does not include the standard design time classes and we need to remove the reference to the System.Design namespace in our present assemblies.

The upcoming release of the VIBlend Controls for Silverlight, which is due in May, will incorporate a full support for Visual Studio 2010. We will also have a new build for Silverlight 4 and our product will benefit from the new features in the latest platform’s edition. In addition, the new release will be shipped with three new themes for all of our controls and performance optimizations in the VIBlend OLAP Grid for Silverlight.

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