Home Forums WinForms controls Xceed Grid for WinForms Help in creating handler

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

    I know absolutely nothing about creating handlers only how to use them. So with that in mind, can someone help me construct a handler (and where the code needs to be placed inside my form) that will allow me to:

    Execute a Database update and a DataSet Acceptchanges whenever a value is changed inside either a Master Grid, or detail grid?

    I know I need to use the Cell.ValueChanged event but I can’t ever get to it or find it.

    master Gridcontrol is named Grid
    detailgrid(0) is named detail which is the master of detail2
    detailgrid(1) is named detail2

    I can get to the cells from the master but can never figure out how to get to the cells in either of the detail grids.

    The tutorials for Xceed grids only do the easy stuff that I understand it’s when things get more complex that I can’t find any info on how it must be accomplished.

    Thanks

    Imported from legacy forums. Posted by Greg (had 3858 views)

    User (Old forums)
    Member
    Post count: 23064

    Are you using C# or VB.NET?

    Imported from legacy forums. Posted by André (had 294 views)

    User (Old forums)
    Member
    Post count: 23064

    Oh, sorry. VB.NET thanks

    Imported from legacy forums. Posted by Greg (had 472 views)

    User (Old forums)
    Member
    Post count: 23064

    Here is a code snippet that shows a very basic implementation of this, and is certainly not recommended with large datasets. It is only an illustration, so you can get you going when using events and DB objects.

    <code>
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    ‘the binding can be done in the designer
    GridControl1.SetDataBinding( DataSet11.Customers, “” )
    detailGridTemplate1.SetDataBinding( DataSet11.Customers, “CustomersOrders” )
    detailGridTemplate2.SetDataBinding( DataSet11.Customers, “CustomersOrders.OrdersOrder_x0020_Details” )

    For Each cell As Cell In dataRowTemplate1.Cells
    AddHandler cell.ValueChanged, AddressOf cell_ValueChanged
    Next

    OleDbDataAdapter1.Fill(DataSet11)
    OleDbDataAdapter2.Fill(DataSet11)
    OleDbDataAdapter3.Fill(DataSet11)

    End Sub

    Private Sub cell_ValueChanged(ByVal sender As Object, ByVal e As EventArgs)

    ‘this updates the DB
    OleDbDataAdapter1.Update(DataSet11)
    OleDbDataAdapter2.Update(DataSet11)
    OleDbDataAdapter3.Update(DataSet11)

    End Sub
    </code>

    Imported from legacy forums. Posted by André (had 229 views)

    User (Old forums)
    Member
    Post count: 23064

    thank you. The part that I was missing and couldn’t figure out was the For Each cell as cell in dataRowTemplate1.Cells snippet.

    I wanted to keep going to detailgrids(0) and couldn’t ever get what I needed.

    Thanks again.

    Imported from legacy forums. Posted by Greg (had 385 views)

    User (Old forums)
    Member
    Post count: 23064

    Of course, you will need to do the same for every DataRowTemplate, since the grid adds one every time you add a DetailGridTemplate (that is, each DetailGridTemplate has its own DataRowTemplate).

    Imported from legacy forums. Posted by André (had 4982 views)

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