Vb.net 我不知道';我不知道如何通过选择单选按钮选项(全职或兼职)在datagridview中显示数据
我需要使用两个单选按钮在datagridview中显示适当的信息,一个是PartTimeRadioButton,另一个是FullTimeRadioButton。当某人选择单选按钮时,它将仅显示全职或兼职人员。我根本不知道该怎么开始。我知道如何通过以下方式显示所有内容: SalesDataGridView.DataSource=aCustomers.Items aCustomers来自Customers类,但以该形式重命名为aCustomers。我附上了这个项目的设计截图。我也必须在晚上11:59之前完成这项工作,但我不知道怎么做 客户类别代码为:Vb.net 我不知道';我不知道如何通过选择单选按钮选项(全职或兼职)在datagridview中显示数据,vb.net,Vb.net,我需要使用两个单选按钮在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
你可能想开始把范围缩小到更具体的问题。