我需要使用两个单选按钮 PartTimeRadioButton 和 FullTimeRadioButton 在 datagridview 中显示适当的信息。当有人选择单选按钮时,它将仅显示全职或兼职人员。我什至不知道如何开始。我知道如何通过以下方式显示所有这些:
SalesDataGridView.DataSource = aCustomers.Items
aCustomers 来自客户类,但以该形式重命名为 aCustomers。我附上了这个项目设计的屏幕截图。我还必须在晚上 11:59 之前完成这项工作,但不知道该怎么做。
客户类代码为:
Public Class Customers
'create a object variable (tableadapter)
'this will be used to creat instances of this class in the form
Private adapter As New CompanyDataSetTableAdapters.SalesStaffTableAdapter
'property to return a table using the GetData method
Public ReadOnly Property Items() As DataTable
Get
Dim table As DataTable = adapter.GetData
table.DefaultView.Sort = "First_Name"
Return table
End Get
End Property
'create a function to filter the customers by custid
Public Function GetByCustomerId(custid As Short) As DataTable
Dim table As DataTable = adapter.GetData 'entire table
'filter to get desired row(s)
table.DefaultView.RowFilter = " ID = " & custid
Return table
End Function
End Class
带有 datagridview 和单选按钮代码的显示窗口窗体是:
' For the datagridview, display only first name, last name, fulltime, hiredate and salary
' If you do not want to display the column, use the visible property.
' For example, SalesDataGridView.Columns(0).Visible = false
' To accumulate the total salary, you can use the cells in the datagridview
' For example, id is in cells(0).
Public Class frmDisplay
Private aCustomers As New Customers
Private formLoading As Boolean = True
Private Sub radFT_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub radPT_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
SalesDataGridView.DataSource = aCustomers.Items
End Sub
End Class