0
我有datagridviews都顯示數據(每個顯示組 - 1和2),基本上他們都顯示部分和插槽號碼和一些其他位,部件號和插槽是主要信息,第一個gridview顯示當前的零件和一個槽號,以及第二個gridview顯示他們將要移動到的下一個零件(零件號和零件槽)。這些組之間有共同點,所以在第一個和第二個gridview中顯示了插槽1中的一個示例1111-1111 - 我需要嘗試的做法是對類似行的第二個gridview背景着色,如果它存在於第一個,但如果它不存在,則將該行着色爲紅色。比較Datagridviews vb.net
我已經得到了所有正確的數據顯示,只需要在第一組紅色中出現的第二個gridview上着色綠色和缺失的相似物。
我試過谷歌但nothings真的工作,我希望你們一個女孩可以幫助。
下面是填充datagridviews的大部分代碼。
connect()
If combo_line.Text = "All" Then
cmd.CommandText = "SELECT v_machine, v_part, v_feedertype, v_slot, v_track FROM [sql_valor_groups] ORDER BY v_machine ASC"
Else
If combo_machine.Text = "All" Then
cmd.CommandText = "SELECT v_machine, v_part, v_feedertype, v_slot, v_track FROM [sql_valor_groups] WHERE v_line = '" & combo_line.Text & "' AND v_group = '" & combo_group.Text & "' ORDER BY v_machine ASC"
cmd2.CommandText = "SELECT v_machine, v_part, v_feedertype, v_slot, v_track FROM [sql_valor_groups] WHERE v_line = '" & combo_line.Text & "' AND v_group = '" & combo_group2.Text & "' ORDER BY v_machine ASC"
Else
cmd.CommandText = "SELECT v_machine, v_part, v_feedertype, v_slot, v_track FROM [sql_valor_groups] WHERE v_line = '" & combo_line.Text & "' AND v_machine = '" & combo_machine.Text & "' AND v_group = '" & combo_group.Text & "' ORDER BY v_machine ASC"
cmd2.CommandText = "SELECT v_machine, v_part, v_feedertype, v_slot, v_track FROM [sql_valor_groups] WHERE v_line = '" & combo_line.Text & "' AND v_machine = '" & combo_machine.Text & "' AND v_group = '" & combo_group2.Text & "' ORDER BY v_machine ASC"
End If
End If
Dim dataAdapter = New SqlDataAdapter(cmd.CommandText, con.ConnectionString)
Dim table As New DataTable()
table.Locale = System.Globalization.CultureInfo.InvariantCulture
dataAdapter.Fill(table)
Me.BindingSource.DataSource = table
DataGridView.DataSource = BindingSource
DataGridView.Columns(0).HeaderText = "Machine:"
DataGridView.Columns(1).HeaderText = "Part:"
DataGridView.Columns(2).HeaderText = "Feeder Type:"
DataGridView.Columns(3).HeaderText = "Slot:"
DataGridView.Columns(4).HeaderText = "Track:"
DataGridView.EnableHeadersVisualStyles = False
DataGridView.RowTemplate.MinimumHeight = 30
Dim dataAdapter2 = New SqlDataAdapter(cmd2.CommandText, con2.ConnectionString)
Dim table2 As New DataTable()
table2.Locale = System.Globalization.CultureInfo.InvariantCulture
dataAdapter2.Fill(table2)
Me.BindingSource2.DataSource = table2
DataGridView2.DataSource = BindingSource2
DataGridView2.Columns(0).HeaderText = "Machine:"
DataGridView2.Columns(1).HeaderText = "Part:"
DataGridView2.Columns(2).HeaderText = "Feeder Type:"
DataGridView2.Columns(3).HeaderText = "Slot:"
DataGridView2.Columns(4).HeaderText = "Track:"
DataGridView2.EnableHeadersVisualStyles = False
DataGridView2.RowTemplate.MinimumHeight = 30
disconnect()