DataGridView in VB.NET

Custom Search

1. Create New Project
2. Drag and Drop the DataGridview  from toolbox




Public
Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'Insert Data in DataGridView

Me
.DataGridView1.Rows.Add(nameTextBox.Text, rollnoTextBox.Text, branchComboBox.SelectedItem, cityListBox.SelectedItem)

End Sub

Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick

'Retrieve data from DataGridView and show it in textboxes


nameupdateTextBox.Text =
Me.DataGridView1.CurrentRow.Cells(0).Value

rollnoupdateTextBox.Text = Me.DataGridView1.CurrentRow.Cells(1).Value

branchupdateTextBox.Text = Me.DataGridView1.CurrentRow.Cells(2).Value

cityupdateTextBox.Text = Me.DataGridView1.CurrentRow.Cells(3).Value

End Sub

Private Sub updateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles updateButton.Click

'Update Data in DataGridView

Me
.DataGridView1.CurrentRow.Cells(0).Value = nameupdateTextBox.Text

Me.DataGridView1.CurrentRow.Cells(1).Value = rollnoupdateTextBox.Text

Me.DataGridView1.CurrentRow.Cells(2).Value = branchupdateTextBox.Text

Me.DataGridView1.CurrentRow.Cells(3).Value = cityupdateTextBox.Text

End Sub

Private Sub deleteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles deleteButton.Click

'Delete Selected Row
Me
.DataGridView1.Rows.Remove(Me.DataGridView1.CurrentRow)

End Sub

End Class




Njoy!!!!!
TING LAK LAK TING TING LAK LAK!!!!!!!!!!!!!!!!!!!




 del.icio.us  Stumbleupon  Technorati  Digg 

 

What did you think of this article?




Trackbacks
  • Trackbacks are closed for this entry.
Comments
Page: 1 of 1
  • 2/22/2009 2:00 PM Sanjeev wrote:
    Sir ,

    What are you trying to tell in this article , we do not get much idea what this article is really about except that
    it is about the Data Gridview .. and what
    else you are trying to do with in article

    Please Try write few lines before you write complete article .


    Thanks
    Sanjeev
    Reply to this

Page: 1 of 1
Leave a comment

Submitted comments will be subject to moderation before being displayed.

 Enter the above security code (required)

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.