VIBlend

Grid cells formatting in VIBlend DataGridView for Windows Forms

by viblend 9. November 2008 19:34

Formatting the value of a grid cell is one of the most common tasks when working with data grids. Most spreadsheet applications like Excel, provide a built-in list with the most common cell formats. These include format expressions for numbers, currencies, dates, hours, and more. In addition, the user can easily create a custom cell format expression.
VIBlend DataGrid for WinForms, allows you to format the content a grid cell through a simple expression which follows the .NET string formatting rules. The value of a grid cell can be any object type, and it is up to you to specify how this value will be converted to text. Unless you associate the cell, or its column, with a format expression, the grid will try to get the text representation of the cell’s value by calling the ToString() method.


The code below formats all cells in the second column of the data grid as dollar values with two digits behind the decimal point:

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            // Create a pseudo-random number generator
            Random rand = new Random();

            // Add two columns
            HierarchyItem column1 = vDataGridView1.ColumnsHierarchy.Items.Add("Unformatted Column");

            HierarchyItem column2 = vDataGridView1.ColumnsHierarchy.Items.Add("Formatted Column");

            // Add 10 rows
            for (int iRow = 0; iRow < 10; iRow++)
            {
                HierarchyItem row = vDataGridView1.RowsHierarchy.Items.Add(string.Format("Row {0}", iRow + 1));

                // Generate a random number
                double value = rand.NextDouble() * 100.0f;

                // Set cell value at (currentRow;column1) and (currentRow;column2) to the random number

                vDataGridView1.CellsArea.SetCellValue(row, column1, value);

                vDataGridView1.CellsArea.SetCellValue(row, column2, value);

                // set the cell alignment to MiddleRight
                vDataGridView1.CellsArea.SetCellTextAlignment(row, column1, ContentAlignment.MiddleRight); vDataGridView1.CellsArea.SetCellTextAlignment(row, column2, ContentAlignment.MiddleRight);

            }

            // Create a named format expression
            vDataGridView1.CellsArea.CellFormatting.SetFormatter("format1", null, "${0:##.00}");

            // Assign the format expression to all cells under the second grid column
            vDataGridView1.CellsArea.CellFormatting.SetCellFormatting(column2, "format1");

            // Refresh the grid's content

            vDataGridView1.Refresh();
        }
    }

In addition, VIBlend DataGridView allows you to use custom format providers to achive maximum flexibility.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

GridView | winforms grid

VIBlend SuperControls for Windows Forms integration with Visual C# Express and Visual Basic Express

by viblend 1. November 2008 08:03

The installation package for VIBlend SuperControls for Windows Forms integrates all of the controls with the Visual Studio toolbox. It does that automatically at the end of the setup. This process works properly with Visual Studio 2005 and Visual Studio 2008 Standard, Professional and Team editions. However, due limitations in the Visual Studio Express editions, this process does not work with Visual C# Express and Visual Basic Express.

If you want to use VIBlend SuperControls for WinForms with Visual C# Express or Visual Basic Express, please follow these steps:

  1. Run the setup program and wait for it to complete the installation
  2. Open Visual C# Express (or Visual Basic Express)
  3. Create a new Windows Forms application
  4. Locate the controls toolbox and expand it
  5. Right click, and select ‘Add Tab’
  6. Type ‘VIBlend’ in the textbox
  7. Right click and select ‘Choose Items…’
  8. Select ‘Browse’ and location the installation folder for VIBlend SuperControls for Windows Forms
  9. Select ‘VIBlendSuperControls.dll’ and click ‘Open’
  10. Repeat the browse step again and select VIBlendSuperGrid.dll
  11. Click Ok


You should see all of the VIBlend controls inside the toolbox.

If you have any questions or problems with the installation process, please, email to: support@viblend.com

Currently rated 4.3 by 3 people

  • Currently 4.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Installing VIBlend Windows Form Controls on Windows Vista

by viblend 1. November 2008 07:26

Windows Vista, Windows 2008 Server and the upcoming Windows 7 include enhanced security compared to earlier Windows versions. Those of you, who are using one of these operating system, know that you are often prompted to allow or block certain actions, which applications and installation programs try to do.

The installation package for VIBlend Windows Forms Controls requires permissions in order to register the library’s DLLs within the global assembly cache (GAC). It also needs permissions to integrate the controls with the Visual Studio's toolbox. In order to perform these actions, the setup has to be executed under elevated privileges.

Follow these steps to properly install VIBlend WinForms Controls:

  1. Unzip setup.exe in an empty folder
  2. Right click on setup.exe
  3. Select 'Run as Administrator'
  4. Allow the setup to run under elevated privileges and follow the setup instructions

Again, this applies to you only if you are running Windows Vista, Windows 2008 server, or a later Windows OS with UAC (User Access Control).
If you have any questions or problems with the installation process, please, email to: support@viblend.com

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

About the author

Some text that describes me

Recent comments

None

Copyright © 2009 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