-1

我需要使用两个单选按钮 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
4

1 回答 1

0
  1. 弄清楚如何只显示全职客户。
  2. 弄清楚如何只显示兼职客户。在第 1 步之后这将很容易。
  3. 当单选按钮更改时,重新加载适当的数据(您在步骤 1 和 2 中所做的)。您可以在 checkedchanged 事件中处理此问题。
于 2012-11-11T22:21:22.717 回答