Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All Brothers

I am working on ERP system and i need one help
I wrote code for Datagrid auto complete.
this code is working perfect but it only showing one Column record from database

what i need is
i want first column is to autocomplete as i did and it should fill related columns automatically linked with first column.

please guide me with Codes

many Thanks

What I have tried:

Dim strConn As String
    Dim da As SqlDataAdapter
    Dim conn As SqlConnection
    Dim ds As New DataSet
    strConn = ("Server= DESKTOP-QN6F623; Database = stock_in;Integrated Security = false;User ID=dis;Password=0m3rP@ss")
    conn = New SqlConnection(strConn)
    da = New SqlDataAdapter("Select * from [items]", conn)
    da.Fill(ds, "items")
    ItemsDataGridView.DataSource = ds.Tables("items")
    Dim cmd As New SqlCommand("Select item_number From items", conn)
    Dim dr As SqlDataReader
    conn.Open()
    dr = cmd.ExecuteReader
    Do While dr.Read
        scAutoComplete.Add(dr.GetString(0))
    Loop
    conn.Close()
Private Sub ItemsDataGridView_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles ItemsDataGridView.EditingControlShowing

    If ItemsDataGridView.CurrentCell.ColumnIndex = 1 AndAlso TypeOf e.Control Is TextBox Then
        With DirectCast(e.Control, TextBox)
            .AutoCompleteMode = AutoCompleteMode.SuggestAppend
            .AutoCompleteSource = AutoCompleteSource.CustomSource
            .AutoCompleteCustomSource = scAutoComplete
        End With
    Else
        With DirectCast(e.Control, TextBox)
            .AutoCompleteMode = Nothing
            .AutoCompleteSource = AutoCompleteSource.CustomSource
            .AutoCompleteCustomSource = Nothing
        End With
    End If
End Sub
Posted
Updated 19-Jan-19 5:29am
v2

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