jsctechy
asked on
Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound.
hi there,
i got this error when i execute this code:
Private Sub frmErrorAcct_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'ErrorAcct._ErrorAcct' table. You can move, or remove it, as needed.
Dim str As String() = {Nothing, "Hello", "Test"}
Me.ErrorAcctDataGridView.C olumns.Add ("REP_P", "P/L")
Me.ErrorAcctDataGridView.R ows.Add(st r)
Me.ErrorAcctTableAdapter.F ill(Me.Err orAcct._Er rorAcct)
End Sub
Any ideas how to fix this
i got this error when i execute this code:
Private Sub frmErrorAcct_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'ErrorAcct._ErrorAcct' table. You can move, or remove it, as needed.
Dim str As String() = {Nothing, "Hello", "Test"}
Me.ErrorAcctDataGridView.C
Me.ErrorAcctDataGridView.R
Me.ErrorAcctTableAdapter.F
End Sub
Any ideas how to fix this
ASKER
can you be a little be more specific?
recordset.addNew willnot work by itself? can you show me how with the code i have provide on my original question?
Thanks
recordset.addNew willnot work by itself? can you show me how with the code i have provide on my original question?
Thanks
Fill your DataGridView first:
Me.ErrorAcctDataGridView.C olumns.Add ("REP_P", "P/L")
Me.ErrorAcctTableAdapter.F ill(Me.Err orAcct._Er rorAcct)
ErrorAcctDataGridView.Data Sourece = ErrorAcct._ErrorAcct
Dim str As String() = {Nothing, "Hello", "Test"}
ErrorAcct._ErrorAcct.Add(s tr)
ErrorAcct._ErrorAcct.EndEd it
Me.ErrorAcctDataGridView.C
Me.ErrorAcctTableAdapter.F
ErrorAcctDataGridView.Data
Dim str As String() = {Nothing, "Hello", "Test"}
ErrorAcct._ErrorAcct.Add(s
ErrorAcct._ErrorAcct.EndEd
ASKER
how do i add a total at the bottom of the column?
lets said i have 4 columns i need a total on column 3 how do i do it without getting this error?
lets said i have 4 columns i need a total on column 3 how do i do it without getting this error?
1. Read data from database and fill System.Data.DataTable
2. Add one boolean column to the newly created DataTable (say colIsSummary) that column might be set to true for the last, summary, row
3. Programmatically add one extra row to datatable that contains suitable summary data
4. Set BindingSource.DataSource propert to this DataTable, set sorting by last column to have summary row always on bottom.
4. Do the data binding to DataGridView control (DataGridView.DataSourse=Y ourBinding Source)
5. Using appropriate event (Button click, Row/CellValidate etc) , bold or otherwise graphically distinct summary row (row that have extra column value set to true)
2. Add one boolean column to the newly created DataTable (say colIsSummary) that column might be set to true for the last, summary, row
3. Programmatically add one extra row to datatable that contains suitable summary data
4. Set BindingSource.DataSource propert to this DataTable, set sorting by last column to have summary row always on bottom.
4. Do the data binding to DataGridView control (DataGridView.DataSourse=Y
5. Using appropriate event (Button click, Row/CellValidate etc) , bold or otherwise graphically distinct summary row (row that have extra column value set to true)
PS Dont forget remove extra column and row from DataTable before saving
ASKER
those 5 steps looks really simple but i only have this amount of code on my form:
Private Sub ErrorAcctBindingNavigatorS aveItem_Cl ick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ErrorAcctBindingNavigatorS aveItem.Cl ick
Me.Validate()
Me.ErrorAcctBindingSource. EndEdit()
Me.ErrorAcctTableAdapter.U pdate(Me.E rrorAcct._ ErrorAcct)
End Sub
Private Sub frmErrorAcct_FormClosed(By Val sender As Object, ByVal e As System.Windows.Forms.FormC losedEvent Args) Handles Me.FormClosed
Me.Validate()
Me.ErrorAcctBindingSource. EndEdit()
Me.ErrorAcctTableAdapter.U pdate(Me.E rrorAcct._ ErrorAcct)
ModMain.DisplayfrmBackGrou nd()
End Sub
Private Sub frmErrorAcct_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'code to store values of the clipboard
Me.ErrorAcctDataGridView.C lipboardCo pyMode = DataGridViewClipboardCopyM ode.Enable WithoutHea derText
'TODO: This line of code loads data into the 'ErrorAcct._ErrorAcct' table. You can move, or remove it, as needed.
Me.ErrorAcctTableAdapter.F ill(Me.Err orAcct._Er rorAcct)
End Sub
how do i do all that that you have just tell me??
=/
Private Sub ErrorAcctBindingNavigatorS
Me.Validate()
Me.ErrorAcctBindingSource.
Me.ErrorAcctTableAdapter.U
End Sub
Private Sub frmErrorAcct_FormClosed(By
Me.Validate()
Me.ErrorAcctBindingSource.
Me.ErrorAcctTableAdapter.U
ModMain.DisplayfrmBackGrou
End Sub
Private Sub frmErrorAcct_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'code to store values of the clipboard
Me.ErrorAcctDataGridView.C
'TODO: This line of code loads data into the 'ErrorAcct._ErrorAcct' table. You can move, or remove it, as needed.
Me.ErrorAcctTableAdapter.F
End Sub
how do i do all that that you have just tell me??
=/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
got an error here Me.ErrorAcctBindingSource. Sorting
sorting is not a menber of system.windows.forms.bindi ngsource
sorting is not a menber of system.windows.forms.bindi
ASKER
and if i do comment that line out i dont get any summary anyways =/
ASKER
anything on this or its abandoned?
recordset.Addnew FieldList, Values
That should inturn add it to the DataGrid....