本文介绍了从组合框中选择customerName时如何自动填充customerAdd文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码:
here is my code:
Imports System.Data.SqlClient
Public Class Form3
Dim cn As SqlConnection
Dim cmd As SqlCommand
Dim dr As SqlDataReader
Dim da As SqlDataAdapter
Dim ds As New DataSet
Dim dt As New DataTable
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn = New SqlConnection("server=localhost;uid=sa;pwd=sa;database=RKPlastics")
cn.Open()
da = New SqlDataAdapter("select * from trial order by name ASC", cn)
da.Fill(dt)
ComboBox1.DataSource = dt
ComboBox1.DisplayMember = "name";
ComboBox1.ValueMember = "id";
ComboBox1.Text = "select value";
ComboBox1.SelectedValue = 1
cn.Close()
End Sub
推荐答案
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim selectedEmployee = CType(ComboBox1.SelectedItem, String)
TextBox1.Text = TextBox1.Text & Microsoft.VisualBasic.vbCrLf & selectedEmployee
End Sub
这篇关于从组合框中选择customerName时如何自动填充customerAdd文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!