我有一个包含两个按钮和一个包含 6 列的数据网格的屏幕。当按下按钮 1 时,它会在行中显示第 1 到第 4 列的数据。当我按下按钮 2 时,我希望我的应用程序填充行中的剩余列(即第 5 列和第 6 列)。
解决方案可能很明显,但我不确定如何解决它。
编辑:对不起,我之前忘了提,当我点击第二个按钮时,数据出现在正确的位置,即最后两列。除非它不在同一行。数据显示在下一行。
这是我的代码:
Private Sub btnClockIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClockIn.Click
Homescreen.DataGridViewEmployee.ColumnCount = 6
Homescreen.DataGridViewEmployee.Columns(0).Name = "Employee Number"
Homescreen.DataGridViewEmployee.Columns(1).Name = "Day"
Homescreen.DataGridViewEmployee.Columns(2).Name = "Week Number"
Homescreen.DataGridViewEmployee.Columns(3).Name = "Time In"
Homescreen.DataGridViewEmployee.Columns(4).Name = "Time Out"
Homescreen.DataGridViewEmployee.Columns(5).Name = "Hours"
Dim row As String() = New String() {ENumber, day, WeekNum, StartTime, "", ""}
Homescreen.DataGridViewEmployee.Rows.Add(row)
Homescreen.DataGridViewEmployee.ReadOnly = True
Private Sub btnClockOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClockOut.Click
Homescreen.DataGridViewEmployee.ColumnCount = 6
Homescreen.DataGridViewEmployee.Columns(0).Name = "Employee Number"
Homescreen.DataGridViewEmployee.Columns(1).Name = "Day"
Homescreen.DataGridViewEmployee.Columns(2).Name = "Week Number"
Homescreen.DataGridViewEmployee.Columns(3).Name = "Time In"
Homescreen.DataGridViewEmployee.Columns(4).Name = "Time Out"
Homescreen.DataGridViewEmployee.Columns(5).Name = "Hours"
Dim row As String() = New String() {"", "", "", "", EndTime, Diff}
Homescreen.DataGridViewEmployee.Rows.Add(row)
Homescreen.DataGridViewEmployee.ReadOnly = True