Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 我不知道';我不知道如何通过选择单选按钮选项(全职或兼职)在datagridview中显示数据_Vb.net - Fatal编程技术网

Vb.net 我不知道';我不知道如何通过选择单选按钮选项(全职或兼职)在datagridview中显示数据

Vb.net 我不知道';我不知道如何通过选择单选按钮选项(全职或兼职)在datagridview中显示数据,vb.net,Vb.net,我需要使用两个单选按钮在datagridview中显示适当的信息,一个是PartTimeRadioButton,另一个是FullTimeRadioButton。当某人选择单选按钮时,它将仅显示全职或兼职人员。我根本不知道该怎么开始。我知道如何通过以下方式显示所有内容: SalesDataGridView.DataSource=aCustomers.Items aCustomers来自Customers类,但以该形式重命名为aCustomers。我附上了这个项目的设计截图。我也必须在晚上11:59

我需要使用两个单选按钮在datagridview中显示适当的信息,一个是PartTimeRadioButton,另一个是FullTimeRadioButton。当某人选择单选按钮时,它将仅显示全职或兼职人员。我根本不知道该怎么开始。我知道如何通过以下方式显示所有内容:

SalesDataGridView.DataSource=aCustomers.Items

aCustomers来自Customers类,但以该形式重命名为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
' 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
带有datagridview和单选按钮代码的显示窗口窗体为:

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
' 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
  • 了解如何仅显示全职客户
  • 了解如何仅显示兼职客户。在步骤1之后,这将很容易
  • 当单选按钮更改时,请重新加载相应的数据(如步骤1和2中所做的)。您可以在checkedchanged事件中处理此问题
    你可能想开始把范围缩小到更具体的问题。