Home Forums WinForms controls Xceed Grid for WinForms Add new row to a DataSet (with DataView) bound Grid

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #12977 |

    Hi!

    How is it possible to add a new row on a grid that is connected with a DataSet that currently has a “DefaultView”-filtering?

    I have look at MSDN, and tried to “translate” it to Xceed grid language but without success.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconmodifyingdatausingdataview.asp

    I would like to do following but the “Dim” line results in an exception “Specified cast is not valid.” Ok, it does not seems that it is possible for the system to merge a DataRowView into a DataRow – but what is the workaround then ?

    Dim newrow As Xceed.Grid.DataRow = xGrid1.DataSource.DefaultView.AddNew()
    newrow.Cells(“GroupID”).Value = g_CurrentGroupID
    newrow.EndEdit()

    xGrid1.SelectedRows.Clear()
    xGrid1.SelectedRows.Add(newrow)
    xGrid1.Scroll(Xceed.Grid.ScrollDirection.BottomPage)

    Relies on your expertice…

    Best Regards
    Benjamin T

    Imported from legacy forums. Posted by BenjaminT (had 2256 views)

    User (Old forums)
    Member
    Post count: 23064

    When I added following code everything works as expected:
    newrow.Cells(“PriceTypeCategoryID”).Value = 0

    I had to set field values on the new row THE SAME VALUES AS USED ON THE CURRENT FILTER. Otherwise they are of course not a part of the grid that is shown.

    I first thought this was taken care of in a dynamic way in the grid. Not…

    Issue closed.

    Best regards Benjamin

    Imported from legacy forums. Posted by BenjaminT (had 3209 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.