我想知道是否有更有效的方法在同一表单上显示多个网格视图。让我说我有4个网格视图显示不同的数据,并希望每当我按下4个按钮之一时显示一个特定的
截至目前,我正在进行此项
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.DealerShipTableAdapter.Fill(Me.HermesZingoDataSet.DealerShip, ComboBox1.SelectedValue)
dateGridView.Visible = False
DataGridViewDealerShip.Visible = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.DateFilterTableAdapter.Fill(Me.dateDataSet.DateFilter, TextBox1.Text, TextBox2.Text)
DataGridViewDealerShip.Visible = False
dateGridView.Visible = True
End Sub
是否有其他方法对此进行编码以使所有其他网格视图可见= false?感谢
答案 0 :(得分:1)
我想你可以做一些类似下面的事情来简化它:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ShowGridView(GridView1)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ShowGridView(GridView2)
End Sub
private sub ShowGridView(gv As GridView)
GridView1.Visible = GridView1 = gv
GridView2.Visible = GridView2 = gv
GridView3.Visible = GridView3 = gv
GridView4.Visible = GridView4 = gv
End sub