Datagrid Autocomplete With Other Field

  • Thread starter Thread starter Omi4u
  • Start date Start date
O

Omi4u

Guest
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

My Code

im 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

Continue reading...
 
Back
Top