Click here to Skip to main content
15,890,436 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here is my code:
VB
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
Posted
Updated 22-Feb-11 0:29am
v2
Comments
Albin Abel 22-Feb-11 6:41am    
is the comboxbox slection changed event? Fill the text box with the name selected or what?. You need to store the information from the database to some local storage like dataset or an object list, if you need to retrieve more information based on the name selected and fill the text box.

Customer Add= New Customer? Then how you know his name in the selection list. I think I am not well understood your question
Sandeep Mewara 22-Feb-11 6:44am    
Set the textbox value on combobox change event. Whats the issue?

1 solution

In this event: ComboBox.SelectedIndexChanged Event[^]

Something like:
VB
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900