本文介绍了从一个表单到另一个表单获取文本框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我需要将文本框中的值从一个表单提取到另一个表单。文本框中显示的值为空。 这是我的代码 私有子显示() connection =新的SqlConnection(con) Dim Sql As String =SELECT ID,来自tblTickets的名称,其中stu ='A'按名称排序 da1 =新SqlDataAdapter(Sql,连接) 'conn.Open() ds1 =新DataSet() Dim commandBuilder1 As SqlCommandBuilder = New SqlCommandBuilder(da1) da1.Fill(ds1,Pub) dsource1.DataSource = ds1.Tables(Pub) connection.Close() DataGridView3.DataSource = dsource1 DataGridView3.Refresh() DataGridView3.Columns(0).Width = 100 DataGridView3.Columns(1).Width = 200 End Sub Private Sub DataGridView3_CellContentClick(ByVal sender As System.Object,ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)处理DataGridView3.CellContentClick i = DataGridView3.CurrentRow.Index Dim dgv As DataGridView = CType(sender,DataGridView) Dim thisCell As DataGridViewCell = dgv.SelectedCells(0) Dim selCell As Integer = thisCell.ColumnIndex Dim sch作为新计划 sch.txtID.Text = DataGridView3.Item(0,i).Value.ToString() 'Form1.txtflight.Text = DataGridView3.Item(1,i).Value。 ToString Me.Dispose() End Sub 我可以知道问题所在吗?解决方案 hi ,I need to fetch the values to textbox from one form to another .The value displayed in the textbox is empty.This is my codePrivate Sub display() connection = New SqlConnection(con) Dim Sql As String = "SELECT ID,Name from tblTickets where stu='A' order by Name" da1 = New SqlDataAdapter(Sql, connection) 'conn.Open() ds1 = New DataSet() Dim commandBuilder1 As SqlCommandBuilder = New SqlCommandBuilder(da1) da1.Fill(ds1, "Pub") dsource1.DataSource = ds1.Tables("Pub") connection.Close() DataGridView3.DataSource = dsource1 DataGridView3.Refresh() DataGridView3.Columns(0).Width = 100 DataGridView3.Columns(1).Width = 200 End SubPrivate Sub DataGridView3_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView3.CellContentClick i = DataGridView3.CurrentRow.Index Dim dgv As DataGridView = CType(sender, DataGridView) Dim thisCell As DataGridViewCell = dgv.SelectedCells(0) Dim selCell As Integer = thisCell.ColumnIndex Dim sch As New Schedules sch.txtID.Text = DataGridView3.Item(0, i).Value.ToString() 'Form1.txtflight.Text = DataGridView3.Item(1, i).Value.ToString Me.Dispose() End SubMay i know where the problem is? 解决方案 这篇关于从一个表单到另一个表单获取文本框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-04 03:26
查看更多