Datagrid view format

kangkungkernitz1081

New member
Joined
Sep 25, 2008
Messages
3
Programming Experience
Beginner
Hello VB.Net Forums,

I had a application that save data on database. Everytime i enter new data it display on datagrid my problem is how can i format my datagrid: the highlighted rows will be on the last item of datagrid;
I also made my application to filter the data before entering to the database so that it doesnt save duplicate values.
here is my code snippet:

VB.NET:
Private Sub Save()
        myAdapter.SelectCommand.CommandText = "Select * from OrderingTable Where ArticleName = '" _
& ArticleNameComboBox.Text & "' AND Color = '" & ColorComboBox.Text & "' AND Size = '" & SizeComboBox.Text & "' "
        myConnection.Open()
        If ArticleNameComboBox.Text = myAdapter.SelectCommand.ExecuteScalar Then
            MessageBox.Show("Item already exist in the Grid", "Duplicate Items", MessageBoxButtons.OK, MessageBoxIcon.Stop)

        Else
            myAdapter.InsertCommand.Parameters("@ArticleName").Value = ArticleNameComboBox.Text
            myAdapter.InsertCommand.Parameters("@Color").Value = ColorComboBox.Text
            myAdapter.InsertCommand.Parameters("@Size").Value = SizeComboBox.Text
            myAdapter.InsertCommand.Parameters("@Quantity").Value = QuantityTextBox.Text

            myAdapter.InsertCommand.ExecuteNonQuery()
        End If
        myConnection.Close()
        SelectAll()

        ArticleNameComboBox.Text = ""
        ColorComboBox.Text = ""
        SizeComboBox.Text = ""

    End Sub
After the "if" statement triggered (msgbox pops-up) i want my datagrid row posistion will be on the duplicate values. I had difficulties doing that!!!!

Ive tried this code but it has overload:
VB.NET:
Private Sub highlightRow() 

Dim partialColumn As New ComboBox 
Dim index As Integer 
For i As Integer = 0 To myDataset.Tables("OrderingTable").Rows.Count - 1 
  partialColumn.Items.Add(myDataset.Tables("OrderingTable").Rows(i).Item(0).ToString _
    & myDataset.Tables("OrderingTable").Rows(i).Item(1).ToString _
    & myDataset.Tables("OrderingTable").Rows(i).Item(2).ToString) 
Next 
partialColumn.FindString(articleBox.Text & colorBox.Text & sizeBox.Text) 
myDataGrid.Select(index)

End Sub

Please someone help me with this.
kangkungkernitz1081
 
Back
Top