I have a combobox bound to a dataview/dataset. Under the CellEnter event of a datgridview I have the following code:
Private Sub DGV_Structure_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_Structure.CellEnter
DV_ContDraw.RowFilter = "" 'Clear filter
DV_ContDraw.RowFilter = "Cont = " & TXT_Contract.Text & " AND Str = '" & DGV_Structure.Rows(DGV_Structure.CurrentRow.Index).Cells("RFIStr").Value & "'"
CB_DrawNo.SelectedText = ""
This filters the dataview that fills the combobox and therefore shows a different list depending upon which row the user selects. My issue is that this is not instant. There is a noticable delay when the user selects a row while the combobox gets filtered through the dataview.
Does anyone know why there could be such a delay and is there a better way of doing this whilst getting the same result?
I have replaced the datafilter code with the following:
'Run a select command on the dataadapter to filter out only the required contract and structure (Section)
SQL_ContDraw.Parameters("@Cont").Value = "" & TXT_Contract.Text & ""
SQL_ContDraw.Parameters("@Str").Value = "" & DGV_Structure.Rows(DGV_Structure.CurrentRow.Index).Cells("RFIStr").Value & ""
SDA_ContDraw.SelectCommand = SQL_ContDraw
SDA_ContDraw.Fill(DS_ContDraw1) ' Fill the dataset (this is used to fill the dataview)
Introducing Parameters into my dataadapter and this works a treat. However, I can't help but think that calling the database everytime I move a row is a bit excessive!