mond007
Active member
Hi
I have a DataGridView Maintenance screen in which I think I was just getting there when I tried to Add Rows of Data. See
My Screen is :
I am using the following code to Add Rows of Data.
It is because I am using : DataGridView1.DataSource = QuestionAnswerData.Tables(0)
I have tried a few ways, DataGridView1.DataSource = QuestionAnswerData.Tables(0)
and Me.DataGridView1.DataSource = Me.BindingSource1
The Error I am getting is that it says I am NOT allowed to Programmatically Add Rows of Data when the data is bound ?
The reason I have to "Add Rows" Programmatically is so that I can have validation and ensure there is at least some data in the 1st key Column.
I may have to restort to using as ListViewBox which has its limitations....
Can anyone offer a way forward.
Thanks Kuldip.
I have a DataGridView Maintenance screen in which I think I was just getting there when I tried to Add Rows of Data. See
VB.NET:
With QuestionAnswerData.Tables("Questions")
.Columns.Add("QuestionID", GetType(Integer))
.Columns.Add("QuestionNo", GetType(String))
.Columns.Add("Question", GetType(String))
.Columns.Add("AnswerSection", GetType(String))
.Columns.Add("AnswerSectionColor", GetType(String))
.Columns.Add("AnswerImage", GetType(String))
.Columns.Add("AnswerHyperlink", GetType(String))
.Columns.Add("AnswerRTFFile", GetType(String))
End With
My Screen is :
I am using the following code to Add Rows of Data.
VB.NET:
Private Sub btnAddQuestion_Click(sender As Object, e As EventArgs) Handles btnAddQuestion.Click
If Me.txtBoxQuestionNo.Text = "" Then
MsgBox("Error, You must Enter a Question No, remaining fields are optional", vbCritical, "Add Question")
Else
Me.DataGridView1.Rows.Add(Me.txtBoxQuestionNo.Text, Me.txtBoxQuestion.Text, txtBoxSection.Text, Me.txtBoxSectionColour.Text, Me.txtBoxImage, txtBoxHyperlink)
'Me.DataGridView1.Refresh()
End If
End Sub
It is because I am using : DataGridView1.DataSource = QuestionAnswerData.Tables(0)
I have tried a few ways, DataGridView1.DataSource = QuestionAnswerData.Tables(0)
and Me.DataGridView1.DataSource = Me.BindingSource1
The Error I am getting is that it says I am NOT allowed to Programmatically Add Rows of Data when the data is bound ?
The reason I have to "Add Rows" Programmatically is so that I can have validation and ensure there is at least some data in the 1st key Column.
I may have to restort to using as ListViewBox which has its limitations....
Can anyone offer a way forward.
Thanks Kuldip.