Private Sub frmVisitor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load dbConnection.ConnectionString = _ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =SNGPLDbase.mdb" dbConnection.Open() daVisitor = New OleDb.OleDbDataAdapter("Select * From Visitor", dbConnection) cmdbVisitor = New OleDb.OleDbCommandBuilder(daVisitor) daVisitor.Fill(dtVisitor) 'Because the DataTable doesn't hold a connection to the data source, you don't need to close it when you're finished. Dim ds As New DataSet Dim drNewRow As DataRow = dtVisitor.NewRow() dtVisitor.Columns(2).DataType = GetType(String) dtVisitor.Columns(0).AutoIncrement = True dtVisitor.Columns(0).AutoIncrementSeed = 10 dtVisitor.Columns(0).AutoIncrementStep = 10 DataGridView1.Refresh() DataGridView1.DataSource = dtVisitor.DefaultView DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect cboVisitorCode.DataSource = dtVisitor.DefaultView cboVisitorCode.DisplayMember = "VisitorCode" AddHandler cboVisitorCode.SelectedIndexChanged, AddressOf cboVisitorCode_SelectedIndexChanged End Sub Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click Me.txtVisitorName.Text = "" Me.txtVehicleNo.Text = "" End Sub Private Sub cboVisitorCode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboVisitorCode.SelectedIndexChanged 'Modified code here for selected row feilds to textbox 'Also for direct select row from datagridview 'for example ' Me.txtVisitorName.Text= "Abc" ' Me.txtVehicleNo.Text = "xyz250" End Sub
how to grab the values from datagridview selected row to textbox
Wed, 08/12/2009 - 13:43
#1
how to grab the values from datagridview selected row to textbox
Ex:
txtVisitorName.Text = DataGridView1.Rows(1).Cells("VisitorName").Value
it shows a record of only one and that is row1 but i need a code to show dynamically row means any row from the DGV or combobox
I don't get what you mean here.
Pages
Add new comment