Can anyone tell me why "Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound." I keep getting an error "Invalid Operation Exception was Unhandled" error.
All I am attempting to do is allow the user to select products from a list(or a second datagridview) and have it added to the datagridview so they do not have to type in every cell since the other cells are not visible because they do not purtain to their needs. Plus they will be able to save all items at the same time.
I was able to get it to accept the first row and then it errors when adding a second row. I tried using the following line:This above line of code would run when or if another item was selected. I was hoping this would insert a new line so that the next item selected could be placed in it but this is when the error occurs. I even tried the following;Code:DataGridView1.Rows.Add()Same error occured. If anyone has any suggestions, I am all ears. I'm at my wits end on this one. If more info is required, let me know.Code:DataGridView1.Rows.Add(New String() {VendorIDLabel1.Text, _ ComboBox1.Text, _ TextBox1.Text, _ TextBox2.Text, _ TextBox3.Text, _ TextBox4.Text, _ CommLabel.Text, _ TaxCollectedLabel1.Text, _ ManagerIDTextBox.Text, _ ManagerNameTextBox.Text, _ DateLabel1.Text})
PS. to answer the question you may be asking yourself is why am I doing it this way, easiest way to explain it is to imagine having multiple stores in one place all using the same teller. Each store has there own product database. Instead of having multiple receipts, I am trying to store all sold products in its own table so I can keep track of what each vendor sells and so I can print all items on 1 receipt.
Sorry the the long winded explaination.




Reply With Quote
