I have a DataGridView the a pull data from a few columns in a table, add 4 columns, 2 for User Entry and one Shift and one for date that are added.
But I want to get rid of the bottom * row at the bottom of the grid.
If I could post a picture i would, but it kind of looks like the following...
Just ignore the -'s, and yes it inserts the shift and date on the blank line.
| MACHINENUMBER | STYLEWIDTH | SPACES | SHIFT | PICKS | RUNTIME | DATE |
1001 - - - - - - - - - - 1060GP0124 - - - 4 - - - 1 - - - 200 - - - 8 - - 02-01-2014
1002 - - - - - - - - - - 1065Gp0124 - - - 2 - - - 1 - - - 230 - - 7.5 - - 02-01-2014
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -1- - - - - - - - - - - - 02-01-2014
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim sql As String
Dim datepicked As Date
datepicked = DateTimePicker1.Text
If CheckBox1.CheckState = False And CheckBox2.CheckState = False And CheckBox3.CheckState = False Then
MessageBox.Show("Please select a Shift")
Exit Sub
End If
If CheckBox1.Checked = True And CheckBox2.Checked = True Then
MessageBox.Show("Please select a One Shift Only")
Exit Sub
End If
If CheckBox2.Checked = True And CheckBox3.Checked = True Then
MessageBox.Show("Please select a One Shift Only")
Exit Sub
End If
If CheckBox1.Checked = True And CheckBox3.Checked = True Then
MessageBox.Show("Please select a One Shift Only")
Exit Sub
End If
If CheckBox1.Checked = True Then
sql = "SELECT MACHINENUMBER, STYLEWIDTH, SPACES FROM Loomset_GVL WHERE RunFlag1 = 1"
ElseIf CheckBox2.Checked = True Then
sql = "SELECT MACHINENUMBER, STYLEWIDTH, SPACES FROM Loomset WHERE RunFlag2 = 1"
ElseIf CheckBox3.Checked = True Then
sql = "SELECT MACHINENUMBER, STYLEWIDTH, SPACES FROM Loomset WHERE RunFlag3 = 1"
End If
Dim sqlCon1 As New SqlConnection("Data Source=SERVER1\DEV01;database=Production;uid=sa;pwd=passwordhere")
Dim daSWC1 As New SqlDataAdapter(sql, sqlCon1)
Dim SQLcmdBuilder1 As New SqlCommandBuilder(daSWC1)
Dim ds1 As New DataSet
Dim AddCol1 As New DataGridViewTextBoxColumn
Dim AddCol2 As New DataGridViewTextBoxColumn
Dim AddCol3 As New DataGridViewTextBoxColumn
Dim AddCol4 As New DataGridViewTextBoxColumn
AddCol1.DataPropertyName = "Shift"
AddCol1.HeaderText = "Shift"
AddCol1.Name = "Shift"
AddCol2.DataPropertyName = "Picks"
AddCol2.HeaderText = "PICKS"
AddCol2.Name = "PICKS"
AddCol3.DataPropertyName = "RunTime"
AddCol3.HeaderText = "RunTime"
AddCol3.Name = "RunTime"
AddCol4.DataPropertyName = "Date"
AddCol4.HeaderText = "Date"
AddCol4.Name = "Date"
AddCol4.DefaultCellStyle.Format = "MM/dd/yyyy"
daSWC1.Fill(ds1, "MACHINENUMBER")
DataGridView1.DataSource = ds1.Tables(0)
DataGridView1.Columns.Add(AddCol1)
For Each dgvr As DataGridViewRow In DataGridView1.Rows
If CheckBox1.Checked Then
dgvr.Cells("Shift").Value = 1
ElseIf CheckBox2.Checked Then
dgvr.Cells("Shift").Value = 2
ElseIf CheckBox3.Checked Then
dgvr.Cells("Shift").Value = 3
End If
Next
DataGridView1.Columns.Add(AddCol2)
DataGridView1.Columns.Add(AddCol3)
DataGridView1.Columns.Add(AddCol4)
For Each dgvr As DataGridViewRow In DataGridView1.Rows
dgvr.Cells("Date").Value = datepicked
Next
End Sub