How to add a button column to the datagrid using vb.net2003
-
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
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 SubHope this helps :-D
Aim small, miss small
-
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
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.