DataGridView Demo in Visual Basic .Net

Download
Download is available until [expire_date]
  • Version
  • Download 127
  • File Size 110.02 KB
  • File Count 1
  • Create Date April 6, 2016
  • Last Updated April 6, 2016

DataGridView Demo in Visual Basic .Net

DataGridView Demo in Visual Basic .Net

The DataGridView control provides a powerful and flexible way to display data in a tabular format. You can use the DataGridView control to show read-only views of a small amount of data, or you can scale it to show editable views of very large sets of data.

In this sample program in vb.net, the user is allowed to add or insert a record in datagridview control as well as to remove an item from the list. This program has no database, which means that the data entered will not be stored, and the datagridview list will be empty when the user closes the program.

Source code:

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
            MessageBox.Show("Fill-up all the fields")
        Else
            DataGridView1.Rows.Add(TextBox1.Text, TextBox2.Text, TextBox3.Text)
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
        End If
    End Sub
   
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        For Each row In DataGridView1.SelectedRows
            DataGridView1.Rows.Remove(row)
        Next
    End Sub
End Class
, , ,

Post navigation

One thought on “DataGridView Demo in Visual Basic .Net

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.