Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to add a button column to the datagrid using vb.net2003

How to add a button column to the datagrid using vb.net2003

Scheduled Pinned Locked Moved Visual Basic
csharpcsshelptutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    g hanuman
    wrote on last edited by
    #1

    Hai, Can you help me to add the button column in the datagrid using vb.net2003. This button i want for the purpose of (When i select one row and if we press enter)i have to close that grid,and goto other Form).. Thanks, Hanuman.G

    hanuman

    T C 2 Replies Last reply
    0
    • G g hanuman

      Hai, Can you help me to add the button column in the datagrid using vb.net2003. This button i want for the purpose of (When i select one row and if we press enter)i have to close that grid,and goto other Form).. Thanks, Hanuman.G

      hanuman

      T Offline
      T Offline
      tatchung
      wrote on last edited by
      #2

      Hello, I'm not totally familiar with vb.net but I think there's an option in the properties box. Try the layout tab. Then just code the opening of the other form like

      Private Sub dgdDataGrid_ButtonClick(ByVal ColIndex As Integer)
      Form1.Show vbModal
      End Sub

      Hope this helps :-D

      Aim small, miss small

      1 Reply Last reply
      0
      • G g hanuman

        Hai, Can you help me to add the button column in the datagrid using vb.net2003. This button i want for the purpose of (When i select one row and if we press enter)i have to close that grid,and goto other Form).. Thanks, Hanuman.G

        hanuman

        C Offline
        C Offline
        chandralekha
        wrote on last edited by
        #3

        For Adding a button to a datagridview first you add a button column to the columns collection.For example I created a buttoncolumn with name "Button".In the column properties i give the text of that column as "Button" and change the property "Use column text For Button Value" as true. In the DataGridView1_CellClick event write the code below Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick If DataGridView1.Item(e.ColumnIndex, e.RowIndex).Value Is "Button" Then MsgBox(DataGridView1.Item(1, e.RowIndex).Value) Me.Visible = False Dim obj As New Form2 obj.Show() obj.TextBox1.Text = DataGridView1.Item(1, e.RowIndex).Value End If End Sub DataGridView1.Item(1, e.RowIndex).Value gives that rows 1st column value.You can use any column of that rows value for the unique identification of that row.Here I passed that value to a TextBox in Form2. In Form2 with respect to that value you can display the needed informations. Hope this information clear your doubt.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups