Format DataGridView Column to Currency or Percantage - Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This tutorial will show you how to format a column in DataGridView to currency or percentage

format datagridview in vb.net

Format Currency button click

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        DataGridView1.Columns(2).DefaultCellStyle.Format = "c"
        DataGridView1.Refresh()
End Sub

Format Column to Percentage

datagridview format percantage


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        DataGridView1.Columns(2).DefaultCellStyle.Format = "p2" 'number 2 represents decimal digits
        DataGridView1.Refresh()
End Sub


Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2017 - All Rights Reserved.